Pull in updates from master
diff --git a/inc/qcbor/qcbor_decode.h b/inc/qcbor/qcbor_decode.h
index c75c923..bf4a042 100644
--- a/inc/qcbor/qcbor_decode.h
+++ b/inc/qcbor/qcbor_decode.h
@@ -1,6 +1,6 @@
/* ===========================================================================
* Copyright (c) 2016-2018, The Linux Foundation.
- * Copyright (c) 2018-2023, Laurence Lundblade.
+ * Copyright (c) 2018-2024, Laurence Lundblade.
* Copyright (c) 2021, Arm Limited.
* All rights reserved.
*
@@ -1481,7 +1481,7 @@
}
static inline bool
-QCBORDecode_IsNotWellFormedError(QCBORError uErr)
+QCBORDecode_IsNotWellFormedError(const QCBORError uErr)
{
if(uErr >= QCBOR_START_OF_NOT_WELL_FORMED_ERRORS &&
uErr <= QCBOR_END_OF_NOT_WELL_FORMED_ERRORS) {
@@ -1492,7 +1492,7 @@
}
static inline bool
-QCBORDecode_IsUnrecoverableError(QCBORError uErr)
+QCBORDecode_IsUnrecoverableError(const QCBORError uErr)
{
if(uErr >= QCBOR_START_OF_UNRECOVERABLE_DECODE_ERRORS &&
uErr <= QCBOR_END_OF_UNRECOVERABLE_DECODE_ERRORS) {
diff --git a/inc/qcbor/qcbor_encode.h b/inc/qcbor/qcbor_encode.h
index d962c5d..6012b25 100644
--- a/inc/qcbor/qcbor_encode.h
+++ b/inc/qcbor/qcbor_encode.h
@@ -1,6 +1,6 @@
/* ===========================================================================
* Copyright (c) 2016-2018, The Linux Foundation.
- * Copyright (c) 2018-2023, Laurence Lundblade.
+ * Copyright (c) 2018-2024, Laurence Lundblade.
* Copyright (c) 2021, Arm Limited.
* All rights reserved.
*
@@ -2276,7 +2276,7 @@
/**
* Encode the "head" of a CBOR data item.
*
- * @param buffer Buffer to output the encoded head to; must be
+ * @param Buffer Buffer to output the encoded head to; must be
* @ref QCBOR_HEAD_BUFFER_SIZE bytes in size.
* @param uMajorType One of CBOR_MAJOR_TYPE_XX.
* @param uMinLen The minimum number of bytes to encode uNumber. Almost
@@ -2310,7 +2310,7 @@
* See also QCBOREncode_AddBytesLenOnly();
*/
UsefulBufC
-QCBOREncode_EncodeHead(UsefulBuf buffer,
+QCBOREncode_EncodeHead(UsefulBuf Buffer,
uint8_t uMajorType,
uint8_t uMinLen,
uint64_t uNumber);
@@ -2319,141 +2319,50 @@
/* =========================================================================
- BEGINNING OF PRIVATE INLINE IMPLEMENTATION
+ BEGINNING OF PRIVATE IMPLEMENTATION
========================================================================= */
-/**
- * @brief Semi-private method to add a buffer full of bytes to encoded output
- *
- * @param[in] pCtx The encoding context to add the integer to.
- * @param[in] uMajorType The CBOR major type of the bytes.
- * @param[in] Bytes The bytes to add.
- *
- * Use QCBOREncode_AddText() or QCBOREncode_AddBytes() or
- * QCBOREncode_AddEncoded() instead. They are inline functions that
- * call this and supply the correct major type. This function is
- * public to make the inline functions work to keep the overall code
- * size down and because the C language has no way to make it private.
- *
- * If this is called the major type should be @c CBOR_MAJOR_TYPE_TEXT_STRING,
- * @c CBOR_MAJOR_TYPE_BYTE_STRING or @c CBOR_MAJOR_NONE_TYPE_RAW. The
- * last one is special for adding already-encoded CBOR.
- */
+/* Semi-private funcion used by public inline functions. See qcbor_encode.c */
void
-QCBOREncode_AddBuffer(QCBOREncodeContext *pCtx,
- uint8_t uMajorType,
- UsefulBufC Bytes);
+QCBOREncode_Private_AddBuffer(QCBOREncodeContext *pCtx,
+ uint8_t uMajorType,
+ UsefulBufC Bytes);
-/**
- * @brief Semi-private method to open a map, array or bstr-wrapped CBOR
- *
- * @param[in] pCtx The context to add to.
- * @param[in] uMajorType The major CBOR type to close
- *
- * Call QCBOREncode_OpenArray(), QCBOREncode_OpenMap() or
- * QCBOREncode_BstrWrap() instead of this.
- */
+/* Semi-private funcion used by public inline functions. See qcbor_encode.c */
void
-QCBOREncode_OpenMapOrArray(QCBOREncodeContext *pCtx, uint8_t uMajorType);
+QCBOREncode_Private_OpenMapOrArray(QCBOREncodeContext *pCtx,
+ uint8_t uMajorType);
-/**
- * @brief Semi-private method to open a map, array with indefinite length
- *
- * @param[in] pCtx The context to add to.
- * @param[in] uMajorType The major CBOR type to close
- *
- * Call QCBOREncode_OpenArrayIndefiniteLength() or
- * QCBOREncode_OpenMapIndefiniteLength() instead of this.
- */
+/* Semi-private funcion used by public inline functions. See qcbor_encode.c */
void
-QCBOREncode_OpenMapOrArrayIndefiniteLength(QCBOREncodeContext *pCtx,
- uint8_t uMajorType);
+QCBOREncode_Private_OpenMapOrArrayIndefiniteLength(QCBOREncodeContext *pCtx,
+ uint8_t uMajorType);
-/**
- * @brief Semi-private method to close a map, array or bstr wrapped CBOR
- *
- * @param[in] pCtx The context to add to.
- * @param[in] uMajorType The major CBOR type to close.
- *
- * Call QCBOREncode_CloseArray() or QCBOREncode_CloseMap() instead of this.
- */
+/* Semi-private funcion used by public inline functions. See qcbor_encode.c */
void
-QCBOREncode_CloseMapOrArray(QCBOREncodeContext *pCtx, uint8_t uMajorType);
+QCBOREncode_Private_CloseMapOrArray(QCBOREncodeContext *pCtx,
+ uint8_t uMajorType);
-/**
- * @brief Semi-private method to close a map, array with indefinite length
- *
- * @param[in] pCtx The context to add to.
- * @param[in] uMajorType The major CBOR type to close.
- *
- * Call QCBOREncode_CloseArrayIndefiniteLength() or
- * QCBOREncode_CloseMapIndefiniteLength() instead of this.
- */
+/* Semi-private funcion used by public inline functions. See qcbor_encode.c */
void
-QCBOREncode_CloseMapOrArrayIndefiniteLength(QCBOREncodeContext *pCtx,
- uint8_t uMajorType);
+QCBOREncode_Private_CloseMapOrArrayIndefiniteLength(QCBOREncodeContext *pCtx,
+ uint8_t uMajorType);
-/**
- * @brief Semi-private method to add simple types.
- *
- * @param[in] pCtx The encoding context to add the simple value to.
- * @param[in] uMinLen Minimum encoding size for uNum. Usually 0.
- * @param[in] uNum One of CBOR_SIMPLEV_FALSE through _UNDEF or other.
- *
- * This is used to add simple types like true and false.
- *
- * Call QCBOREncode_AddBool(), QCBOREncode_AddNULL(),
- * QCBOREncode_AddUndef() instead of this.
- *
- * This function can add simple values that are not defined by CBOR
- * yet. This expansion point in CBOR should not be used unless they are
- * standardized.
- *
- * Error handling is the same as QCBOREncode_AddInt64().
- */
+/* Semi-private funcion used by public inline functions. See qcbor_encode.c */
void
-QCBOREncode_AddType7(QCBOREncodeContext *pCtx,
- uint8_t uMinLen,
- uint64_t uNum);
+QCBOREncode_Private_AddType7(QCBOREncodeContext *pCtx,
+ uint8_t uMinLen,
+ uint64_t uNum);
-/**
- * @brief Semi-private method to add bigfloats and decimal fractions.
- *
- * @param[in] pCtx The encoding context to add the value to.
- * @param[in] uTag The type 6 tag indicating what this is to be.
- * @param[in] BigNumMantissa Is @ref NULLUsefulBufC if mantissa is an
- * @c int64_t or the actual big number mantissa
- * if not.
- * @param[in] bBigNumIsNegative This is @c true if the big number is negative.
- * @param[in] nMantissa The @c int64_t mantissa if it is not a big number.
- * @param[in] nExponent The exponent.
- *
- * This outputs either the @ref CBOR_TAG_DECIMAL_FRACTION or
- * @ref CBOR_TAG_BIGFLOAT tag. if @c uTag is @ref CBOR_TAG_INVALID64,
- * then this outputs the "borrowed" content format.
- *
- * The tag content output by this is an array with two members, the
- * exponent and then the mantissa. The mantissa can be either a big
- * number or an @c int64_t.
- *
- * This implementation cannot output an exponent further from 0 than
- * @c INT64_MAX.
- *
- * To output a mantissa that is between INT64_MAX and UINT64_MAX from 0,
- * it must be as a big number.
- *
- * Typically, QCBOREncode_AddDecimalFraction(), QCBOREncode_AddBigFloat(),
- * QCBOREncode_AddDecimalFractionBigNum() or QCBOREncode_AddBigFloatBigNum()
- * is called instead of this.
- */
+/* Semi-private funcion used by public inline functions. See qcbor_encode.c */
void
-QCBOREncode_AddExponentAndMantissa(QCBOREncodeContext *pCtx,
+QCBOREncode_Private_AddExpMantissa(QCBOREncodeContext *pCtx,
uint64_t uTag,
UsefulBufC BigNumMantissa,
bool bBigNumIsNegative,
@@ -2466,6 +2375,8 @@
* @param[in] pCtx The context to initialize.
* @param[in] Bytes Pointer and length of the input data.
*
+ * This will be removed in QCBOR 2.0. It was never a public function.
+ *
* This is the same as QCBOREncode_AddBytes() except it only adds the
* CBOR encoding for the type and the length. It doesn't actually add
* the bytes. You can't actually produce correct CBOR with this and
@@ -2481,17 +2392,19 @@
* tested function.
*
* See also QCBOREncode_EncodeHead().
-*/
-static inline void
+ *
+ * TODO: remove this in QCBOR 2.0
+ */
+static void
QCBOREncode_AddBytesLenOnly(QCBOREncodeContext *pCtx,
UsefulBufC Bytes);
-static inline void
+static void
QCBOREncode_AddBytesLenOnlyToMap(QCBOREncodeContext *pCtx,
const char *szLabel,
UsefulBufC Bytes);
-static inline void
+static void
QCBOREncode_AddBytesLenOnlyToMapN(QCBOREncodeContext *pCtx,
int64_t nLabel,
UsefulBufC Bytes);
@@ -2503,19 +2416,19 @@
static inline void
QCBOREncode_AddInt64ToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- int64_t uNum)
+ const int64_t uNum)
{
/* Use _AddBuffer() because _AddSZString() is defined below, not above */
- QCBOREncode_AddBuffer(pMe,
- CBOR_MAJOR_TYPE_TEXT_STRING,
- UsefulBuf_FromSZ(szLabel));
+ QCBOREncode_Private_AddBuffer(pMe,
+ CBOR_MAJOR_TYPE_TEXT_STRING,
+ UsefulBuf_FromSZ(szLabel));
QCBOREncode_AddInt64(pMe, uNum);
}
static inline void
QCBOREncode_AddInt64ToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- int64_t uNum)
+ const int64_t nLabel,
+ const int64_t uNum)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddInt64(pMe, uNum);
@@ -2525,19 +2438,19 @@
static inline void
QCBOREncode_AddUInt64ToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- uint64_t uNum)
+ const uint64_t uNum)
{
/* Use _AddBuffer() because _AddSZString() is defined below, not above */
- QCBOREncode_AddBuffer(pMe,
- CBOR_MAJOR_TYPE_TEXT_STRING,
- UsefulBuf_FromSZ(szLabel));
+ QCBOREncode_Private_AddBuffer(pMe,
+ CBOR_MAJOR_TYPE_TEXT_STRING,
+ UsefulBuf_FromSZ(szLabel));
QCBOREncode_AddUInt64(pMe, uNum);
}
static inline void
QCBOREncode_AddUInt64ToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint64_t uNum)
+ const int64_t nLabel,
+ const uint64_t uNum)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddUInt64(pMe, uNum);
@@ -2545,15 +2458,15 @@
static inline void
-QCBOREncode_AddText(QCBOREncodeContext *pMe, UsefulBufC Text)
+QCBOREncode_AddText(QCBOREncodeContext *pMe, const UsefulBufC Text)
{
- QCBOREncode_AddBuffer(pMe, CBOR_MAJOR_TYPE_TEXT_STRING, Text);
+ QCBOREncode_Private_AddBuffer(pMe, CBOR_MAJOR_TYPE_TEXT_STRING, Text);
}
static inline void
QCBOREncode_AddTextToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Text)
+ const UsefulBufC Text)
{
QCBOREncode_AddText(pMe, UsefulBuf_FromSZ(szLabel));
QCBOREncode_AddText(pMe, Text);
@@ -2561,8 +2474,8 @@
static inline void
QCBOREncode_AddTextToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Text)
+ const int64_t nLabel,
+ const UsefulBufC Text)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddText(pMe, Text);
@@ -2586,7 +2499,7 @@
static inline void
QCBOREncode_AddSZStringToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
const char *szString)
{
QCBOREncode_AddInt64(pMe, nLabel);
@@ -2598,7 +2511,7 @@
static inline void
QCBOREncode_AddDoubleToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- double dNum)
+ const double dNum)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddDouble(pMe, dNum);
@@ -2606,8 +2519,8 @@
static inline void
QCBOREncode_AddDoubleToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- double dNum)
+ const int64_t nLabel,
+ const double dNum)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddDouble(pMe, dNum);
@@ -2616,14 +2529,16 @@
static inline void
QCBOREncode_AddFloatToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- float dNum)
+ const float dNum)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddFloat(pMe, dNum);
}
static inline void
-QCBOREncode_AddFloatToMapN(QCBOREncodeContext *pMe, int64_t nLabel, float fNum)
+QCBOREncode_AddFloatToMapN(QCBOREncodeContext *pMe,
+ const int64_t nLabel,
+ const float fNum)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddFloat(pMe, fNum);
@@ -2632,7 +2547,7 @@
static inline void
QCBOREncode_AddDoubleNoPreferredToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- double dNum)
+ const double dNum)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddDoubleNoPreferred(pMe, dNum);
@@ -2640,8 +2555,8 @@
static inline void
QCBOREncode_AddDoubleNoPreferredToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- double dNum)
+ const int64_t nLabel,
+ const double dNum)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddDoubleNoPreferred(pMe, dNum);
@@ -2650,7 +2565,7 @@
static inline void
QCBOREncode_AddFloatNoPreferredToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- float dNum)
+ const float dNum)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddFloatNoPreferred(pMe, dNum);
@@ -2658,8 +2573,8 @@
static inline void
QCBOREncode_AddFloatNoPreferredToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- float dNum)
+ const int64_t nLabel,
+ const float dNum)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddFloatNoPreferred(pMe, dNum);
@@ -2669,7 +2584,9 @@
static inline void
-QCBOREncode_AddTDateEpoch(QCBOREncodeContext *pMe, uint8_t uTag, int64_t nDate)
+QCBOREncode_AddTDateEpoch(QCBOREncodeContext *pMe,
+ const uint8_t uTag,
+ const int64_t nDate)
{
if(uTag == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_DATE_EPOCH);
@@ -2680,8 +2597,8 @@
static inline void
QCBOREncode_AddTDateEpochToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTag,
- int64_t nDate)
+ const uint8_t uTag,
+ const int64_t nDate)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTDateEpoch(pMe, uTag, nDate);
@@ -2689,16 +2606,17 @@
static inline void
QCBOREncode_AddTDateEpochToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTag,
- int64_t nDate)
+ const int64_t nLabel,
+ const uint8_t uTag,
+ const int64_t nDate)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTDateEpoch(pMe, uTag, nDate);
}
static inline void
-QCBOREncode_AddDateEpoch(QCBOREncodeContext *pMe, int64_t nDate)
+QCBOREncode_AddDateEpoch(QCBOREncodeContext *pMe,
+ const int64_t nDate)
{
QCBOREncode_AddTDateEpoch(pMe, QCBOR_ENCODE_AS_TAG, nDate);
}
@@ -2706,7 +2624,7 @@
static inline void
QCBOREncode_AddDateEpochToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- int64_t nDate)
+ const int64_t nDate)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddDateEpoch(pMe, nDate);
@@ -2714,8 +2632,8 @@
static inline void
QCBOREncode_AddDateEpochToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- int64_t nDate)
+ const int64_t nLabel,
+ const int64_t nDate)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddDateEpoch(pMe, nDate);
@@ -2723,7 +2641,9 @@
static inline void
-QCBOREncode_AddTDaysEpoch(QCBOREncodeContext *pMe, uint8_t uTag, int64_t nDays)
+QCBOREncode_AddTDaysEpoch(QCBOREncodeContext *pMe,
+ const uint8_t uTag,
+ const int64_t nDays)
{
if(uTag == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_DAYS_EPOCH);
@@ -2734,8 +2654,8 @@
static inline void
QCBOREncode_AddTDaysEpochToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTag,
- int64_t nDays)
+ const uint8_t uTag,
+ const int64_t nDays)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTDaysEpoch(pMe, uTag, nDays);
@@ -2743,9 +2663,9 @@
static inline void
QCBOREncode_AddTDaysEpochToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTag,
- int64_t nDays)
+ const int64_t nLabel,
+ const uint8_t uTag,
+ const int64_t nDays)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTDaysEpoch(pMe, uTag, nDays);
@@ -2753,15 +2673,16 @@
static inline void
-QCBOREncode_AddBytes(QCBOREncodeContext *pMe, UsefulBufC Bytes)
+QCBOREncode_AddBytes(QCBOREncodeContext *pMe,
+ const UsefulBufC Bytes)
{
- QCBOREncode_AddBuffer(pMe, CBOR_MAJOR_TYPE_BYTE_STRING, Bytes);
+ QCBOREncode_Private_AddBuffer(pMe, CBOR_MAJOR_TYPE_BYTE_STRING, Bytes);
}
static inline void
QCBOREncode_AddBytesToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Bytes)
+ const UsefulBufC Bytes)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddBytes(pMe, Bytes);
@@ -2769,8 +2690,8 @@
static inline void
QCBOREncode_AddBytesToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddBytes(pMe, Bytes);
@@ -2787,7 +2708,7 @@
static inline void
QCBOREncode_OpenBytesInMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
UsefulBuf *pPlace)
{
QCBOREncode_AddInt64(pMe, nLabel);
@@ -2795,15 +2716,15 @@
}
static inline void
-QCBOREncode_AddBytesLenOnly(QCBOREncodeContext *pMe, UsefulBufC Bytes)
+QCBOREncode_AddBytesLenOnly(QCBOREncodeContext *pMe, const UsefulBufC Bytes)
{
- QCBOREncode_AddBuffer(pMe, CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY, Bytes);
+ QCBOREncode_Private_AddBuffer(pMe, CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY, Bytes);
}
static inline void
QCBOREncode_AddBytesLenOnlyToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Bytes)
+ const UsefulBufC Bytes)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddBytesLenOnly(pMe, Bytes);
@@ -2811,8 +2732,8 @@
static inline void
QCBOREncode_AddBytesLenOnlyToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddBytesLenOnly(pMe, Bytes);
@@ -2821,8 +2742,8 @@
static inline void
QCBOREncode_AddTBinaryUUID(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_BIN_UUID);
@@ -2833,8 +2754,8 @@
static inline void
QCBOREncode_AddTBinaryUUIDToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTBinaryUUID(pMe, uTagRequirement, Bytes);
@@ -2842,16 +2763,16 @@
static inline void
QCBOREncode_AddTBinaryUUIDToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTBinaryUUID(pMe, uTagRequirement, Bytes);
}
static inline void
-QCBOREncode_AddBinaryUUID(QCBOREncodeContext *pMe, UsefulBufC Bytes)
+QCBOREncode_AddBinaryUUID(QCBOREncodeContext *pMe, const UsefulBufC Bytes)
{
QCBOREncode_AddTBinaryUUID(pMe, QCBOR_ENCODE_AS_TAG, Bytes);
}
@@ -2859,15 +2780,15 @@
static inline void
QCBOREncode_AddBinaryUUIDToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Bytes)
+ const UsefulBufC Bytes)
{
QCBOREncode_AddTBinaryUUIDToMapSZ(pMe, szLabel, QCBOR_ENCODE_AS_TAG, Bytes);
}
static inline void
QCBOREncode_AddBinaryUUIDToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddTBinaryUUIDToMapN(pMe,
nLabel,
@@ -2878,8 +2799,8 @@
static inline void
QCBOREncode_AddTPositiveBignum(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_POS_BIGNUM);
@@ -2890,8 +2811,8 @@
static inline void
QCBOREncode_AddTPositiveBignumToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTPositiveBignum(pMe, uTagRequirement, Bytes);
@@ -2899,16 +2820,16 @@
static inline void
QCBOREncode_AddTPositiveBignumToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTPositiveBignum(pMe, uTagRequirement, Bytes);
}
static inline void
-QCBOREncode_AddPositiveBignum(QCBOREncodeContext *pMe, UsefulBufC Bytes)
+QCBOREncode_AddPositiveBignum(QCBOREncodeContext *pMe, const UsefulBufC Bytes)
{
QCBOREncode_AddTPositiveBignum(pMe, QCBOR_ENCODE_AS_TAG, Bytes);
}
@@ -2916,7 +2837,7 @@
static inline void
QCBOREncode_AddPositiveBignumToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Bytes)
+ const UsefulBufC Bytes)
{
QCBOREncode_AddTPositiveBignumToMapSZ(pMe,
szLabel,
@@ -2926,8 +2847,8 @@
static inline void
QCBOREncode_AddPositiveBignumToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddTPositiveBignumToMapN(pMe,
nLabel,
@@ -2938,8 +2859,8 @@
static inline void
QCBOREncode_AddTNegativeBignum(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_NEG_BIGNUM);
@@ -2950,8 +2871,8 @@
static inline void
QCBOREncode_AddTNegativeBignumToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTNegativeBignum(pMe, uTagRequirement, Bytes);
@@ -2959,16 +2880,16 @@
static inline void
QCBOREncode_AddTNegativeBignumToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTNegativeBignum(pMe, uTagRequirement, Bytes);
}
static inline void
-QCBOREncode_AddNegativeBignum(QCBOREncodeContext *pMe, UsefulBufC Bytes)
+QCBOREncode_AddNegativeBignum(QCBOREncodeContext *pMe, const UsefulBufC Bytes)
{
QCBOREncode_AddTNegativeBignum(pMe, QCBOR_ENCODE_AS_TAG, Bytes);
}
@@ -2976,7 +2897,7 @@
static inline void
QCBOREncode_AddNegativeBignumToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Bytes)
+ const UsefulBufC Bytes)
{
QCBOREncode_AddTNegativeBignumToMapSZ(pMe,
szLabel,
@@ -2986,8 +2907,8 @@
static inline void
QCBOREncode_AddNegativeBignumToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddTNegativeBignumToMapN(pMe,
nLabel,
@@ -3001,9 +2922,9 @@
static inline void
QCBOREncode_AddTDecimalFraction(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- int64_t nMantissa,
- int64_t nBase10Exponent)
+ const uint8_t uTagRequirement,
+ const int64_t nMantissa,
+ const int64_t nBase10Exponent)
{
uint64_t uTag;
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
@@ -3011,7 +2932,7 @@
} else {
uTag = CBOR_TAG_INVALID64;
}
- QCBOREncode_AddExponentAndMantissa(pMe,
+ QCBOREncode_Private_AddExpMantissa(pMe,
uTag,
NULLUsefulBufC,
false,
@@ -3022,9 +2943,9 @@
static inline void
QCBOREncode_AddTDecimalFractionToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- int64_t nMantissa,
- int64_t nBase10Exponent)
+ const uint8_t uTagRequirement,
+ const int64_t nMantissa,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTDecimalFraction(pMe,
@@ -3035,10 +2956,10 @@
static inline void
QCBOREncode_AddTDecimalFractionToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- int64_t nMantissa,
- int64_t nBase10Exponent)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const int64_t nMantissa,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTDecimalFraction(pMe,
@@ -3049,8 +2970,8 @@
static inline void
QCBOREncode_AddDecimalFraction(QCBOREncodeContext *pMe,
- int64_t nMantissa,
- int64_t nBase10Exponent)
+ const int64_t nMantissa,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddTDecimalFraction(pMe,
QCBOR_ENCODE_AS_TAG,
@@ -3061,8 +2982,8 @@
static inline void
QCBOREncode_AddDecimalFractionToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- int64_t nMantissa,
- int64_t nBase10Exponent)
+ const int64_t nMantissa,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddTDecimalFractionToMapSZ(pMe,
szLabel,
@@ -3073,9 +2994,9 @@
static inline void
QCBOREncode_AddDecimalFractionToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- int64_t nMantissa,
- int64_t nBase10Exponent)
+ const int64_t nLabel,
+ const int64_t nMantissa,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddTDecimalFractionToMapN(pMe,
nLabel,
@@ -3088,10 +3009,10 @@
static inline void
QCBOREncode_AddTDecimalFractionBigNum(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase10Exponent)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase10Exponent)
{
uint64_t uTag;
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
@@ -3099,9 +3020,10 @@
} else {
uTag = CBOR_TAG_INVALID64;
}
- QCBOREncode_AddExponentAndMantissa(pMe,
+ QCBOREncode_Private_AddExpMantissa(pMe,
uTag,
- Mantissa, bIsNegative,
+ Mantissa,
+ bIsNegative,
0,
nBase10Exponent);
}
@@ -3109,10 +3031,10 @@
static inline void
QCBOREncode_AddTDecimalFractionBigNumToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase10Exponent)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTDecimalFractionBigNum(pMe,
@@ -3124,11 +3046,11 @@
static inline void
QCBOREncode_AddTDecimalFractionBigNumToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase10Exponent)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTDecimalFractionBigNum(pMe,
@@ -3140,9 +3062,9 @@
static inline void
QCBOREncode_AddDecimalFractionBigNum(QCBOREncodeContext *pMe,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase10Exponent)
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddTDecimalFractionBigNum(pMe,
QCBOR_ENCODE_AS_TAG,
@@ -3154,9 +3076,9 @@
static inline void
QCBOREncode_AddDecimalFractionBigNumToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase10Exponent)
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase10Exponent)
{
QCBOREncode_AddTDecimalFractionBigNumToMapSZ(pMe,
szLabel,
@@ -3168,10 +3090,10 @@
static inline void
QCBOREncode_AddDecimalFractionBigNumToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase2Exponent)
+ const int64_t nLabel,
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddTDecimalFractionBigNumToMapN(pMe,
nLabel,
@@ -3187,9 +3109,9 @@
static inline void
QCBOREncode_AddTBigFloat(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- int64_t nMantissa,
- int64_t nBase2Exponent)
+ const uint8_t uTagRequirement,
+ const int64_t nMantissa,
+ const int64_t nBase2Exponent)
{
uint64_t uTag;
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
@@ -3197,7 +3119,7 @@
} else {
uTag = CBOR_TAG_INVALID64;
}
- QCBOREncode_AddExponentAndMantissa(pMe,
+ QCBOREncode_Private_AddExpMantissa(pMe,
uTag,
NULLUsefulBufC,
false,
@@ -3208,9 +3130,9 @@
static inline void
QCBOREncode_AddTBigFloatToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- int64_t nMantissa,
- int64_t nBase2Exponent)
+ const uint8_t uTagRequirement,
+ const int64_t nMantissa,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTBigFloat(pMe, uTagRequirement, nMantissa, nBase2Exponent);
@@ -3218,10 +3140,10 @@
static inline void
QCBOREncode_AddTBigFloatToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- int64_t nMantissa,
- int64_t nBase2Exponent)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const int64_t nMantissa,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTBigFloat(pMe, uTagRequirement, nMantissa, nBase2Exponent);
@@ -3229,8 +3151,8 @@
static inline void
QCBOREncode_AddBigFloat(QCBOREncodeContext *pMe,
- int64_t nMantissa,
- int64_t nBase2Exponent)
+ const int64_t nMantissa,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddTBigFloat(pMe,
QCBOR_ENCODE_AS_TAG,
@@ -3241,8 +3163,8 @@
static inline void
QCBOREncode_AddBigFloatToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- int64_t nMantissa,
- int64_t nBase2Exponent)
+ const int64_t nMantissa,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddTBigFloatToMapSZ(pMe,
szLabel,
@@ -3253,9 +3175,9 @@
static inline void
QCBOREncode_AddBigFloatToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- int64_t nMantissa,
- int64_t nBase2Exponent)
+ const int64_t nLabel,
+ const int64_t nMantissa,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddTBigFloatToMapN(pMe,
nLabel,
@@ -3268,10 +3190,10 @@
static inline void
QCBOREncode_AddTBigFloatBigNum(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase2Exponent)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase2Exponent)
{
uint64_t uTag;
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
@@ -3279,7 +3201,7 @@
} else {
uTag = CBOR_TAG_INVALID64;
}
- QCBOREncode_AddExponentAndMantissa(pMe,
+ QCBOREncode_Private_AddExpMantissa(pMe,
uTag,
Mantissa,
bIsNegative,
@@ -3290,10 +3212,10 @@
static inline void
QCBOREncode_AddTBigFloatBigNumToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase2Exponent)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTBigFloatBigNum(pMe,
@@ -3305,11 +3227,11 @@
static inline void
QCBOREncode_AddTBigFloatBigNumToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase2Exponent)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTBigFloatBigNum(pMe,
@@ -3322,9 +3244,9 @@
static inline void
QCBOREncode_AddBigFloatBigNum(QCBOREncodeContext *pMe,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase2Exponent)
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddTBigFloatBigNum(pMe,
QCBOR_ENCODE_AS_TAG,
@@ -3335,9 +3257,9 @@
static inline void
QCBOREncode_AddBigFloatBigNumToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase2Exponent)
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddTBigFloatBigNumToMapSZ(pMe,
szLabel,
@@ -3349,10 +3271,10 @@
static inline void
QCBOREncode_AddBigFloatBigNumToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Mantissa,
- bool bIsNegative,
- int64_t nBase2Exponent)
+ const int64_t nLabel,
+ const UsefulBufC Mantissa,
+ const bool bIsNegative,
+ const int64_t nBase2Exponent)
{
QCBOREncode_AddTBigFloatBigNumToMapN(pMe,
nLabel,
@@ -3366,8 +3288,8 @@
static inline void
QCBOREncode_AddTURI(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC URI)
+ const uint8_t uTagRequirement,
+ const UsefulBufC URI)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_URI);
@@ -3378,8 +3300,8 @@
static inline void
QCBOREncode_AddTURIToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC URI)
+ const uint8_t uTagRequirement,
+ const UsefulBufC URI)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTURI(pMe, uTagRequirement, URI);
@@ -3387,16 +3309,16 @@
static inline void
QCBOREncode_AddTURIToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC URI)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC URI)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTURI(pMe, uTagRequirement, URI);
}
static inline void
-QCBOREncode_AddURI(QCBOREncodeContext *pMe, UsefulBufC URI)
+QCBOREncode_AddURI(QCBOREncodeContext *pMe, const UsefulBufC URI)
{
QCBOREncode_AddTURI(pMe, QCBOR_ENCODE_AS_TAG, URI);
}
@@ -3404,15 +3326,15 @@
static inline void
QCBOREncode_AddURIToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC URI)
+ const UsefulBufC URI)
{
QCBOREncode_AddTURIToMapSZ(pMe, szLabel, QCBOR_ENCODE_AS_TAG, URI);
}
static inline void
QCBOREncode_AddURIToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC URI)
+ const int64_t nLabel,
+ const UsefulBufC URI)
{
QCBOREncode_AddTURIToMapN(pMe, nLabel, QCBOR_ENCODE_AS_TAG, URI);
}
@@ -3421,8 +3343,8 @@
static inline void
QCBOREncode_AddTB64Text(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC B64Text)
+ const uint8_t uTagRequirement,
+ const UsefulBufC B64Text)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_B64);
@@ -3433,8 +3355,8 @@
static inline void
QCBOREncode_AddTB64TextToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC B64Text)
+ const uint8_t uTagRequirement,
+ const UsefulBufC B64Text)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTB64Text(pMe, uTagRequirement, B64Text);
@@ -3442,16 +3364,16 @@
static inline void
QCBOREncode_AddTB64TextToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC B64Text)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC B64Text)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTB64Text(pMe, uTagRequirement, B64Text);
}
static inline void
-QCBOREncode_AddB64Text(QCBOREncodeContext *pMe, UsefulBufC B64Text)
+QCBOREncode_AddB64Text(QCBOREncodeContext *pMe, const UsefulBufC B64Text)
{
QCBOREncode_AddTB64Text(pMe, QCBOR_ENCODE_AS_TAG, B64Text);
}
@@ -3459,15 +3381,15 @@
static inline void
QCBOREncode_AddB64TextToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC B64Text)
+ const UsefulBufC B64Text)
{
QCBOREncode_AddTB64TextToMapSZ(pMe, szLabel, QCBOR_ENCODE_AS_TAG, B64Text);
}
static inline void
QCBOREncode_AddB64TextToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC B64Text)
+ const int64_t nLabel,
+ const UsefulBufC B64Text)
{
QCBOREncode_AddTB64TextToMapN(pMe, nLabel, QCBOR_ENCODE_AS_TAG, B64Text);
}
@@ -3476,8 +3398,8 @@
static inline void
QCBOREncode_AddTB64URLText(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC B64Text)
+ const uint8_t uTagRequirement,
+ const UsefulBufC B64Text)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_B64URL);
@@ -3488,8 +3410,8 @@
static inline void
QCBOREncode_AddTB64URLTextToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC B64Text)
+ const uint8_t uTagRequirement,
+ const UsefulBufC B64Text)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTB64URLText(pMe, uTagRequirement, B64Text);
@@ -3497,16 +3419,16 @@
static inline void
QCBOREncode_AddTB64URLTextToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC B64Text)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC B64Text)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTB64URLText(pMe, uTagRequirement, B64Text);
}
static inline void
-QCBOREncode_AddB64URLText(QCBOREncodeContext *pMe, UsefulBufC B64Text)
+QCBOREncode_AddB64URLText(QCBOREncodeContext *pMe, const UsefulBufC B64Text)
{
QCBOREncode_AddTB64URLText(pMe, QCBOR_ENCODE_AS_TAG, B64Text);
}
@@ -3514,7 +3436,7 @@
static inline void
QCBOREncode_AddB64URLTextToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC B64Text)
+ const UsefulBufC B64Text)
{
QCBOREncode_AddTB64URLTextToMapSZ(pMe,
szLabel,
@@ -3524,8 +3446,8 @@
static inline void
QCBOREncode_AddB64URLTextToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC B64Text)
+ const int64_t nLabel,
+ const UsefulBufC B64Text)
{
QCBOREncode_AddTB64URLTextToMapN(pMe, nLabel, QCBOR_ENCODE_AS_TAG, B64Text);
}
@@ -3534,8 +3456,8 @@
static inline void
QCBOREncode_AddTRegex(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_REGEX);
@@ -3546,8 +3468,8 @@
static inline void
QCBOREncode_AddTRegexToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTRegex(pMe, uTagRequirement, Bytes);
@@ -3555,16 +3477,16 @@
static inline void
QCBOREncode_AddTRegexToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTRegex(pMe, uTagRequirement, Bytes);
}
static inline void
-QCBOREncode_AddRegex(QCBOREncodeContext *pMe, UsefulBufC Bytes)
+QCBOREncode_AddRegex(QCBOREncodeContext *pMe, const UsefulBufC Bytes)
{
QCBOREncode_AddTRegex(pMe, QCBOR_ENCODE_AS_TAG, Bytes);
}
@@ -3572,15 +3494,15 @@
static inline void
QCBOREncode_AddRegexToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Bytes)
+ const UsefulBufC Bytes)
{
QCBOREncode_AddTRegexToMapSZ(pMe, szLabel, QCBOR_ENCODE_AS_TAG, Bytes);
}
static inline void
QCBOREncode_AddRegexToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Bytes)
+ const int64_t nLabel,
+ const UsefulBufC Bytes)
{
QCBOREncode_AddTRegexToMapN(pMe, nLabel, QCBOR_ENCODE_AS_TAG, Bytes);
@@ -3589,8 +3511,8 @@
static inline void
QCBOREncode_AddTMIMEData(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC MIMEData)
+ const uint8_t uTagRequirement,
+ const UsefulBufC MIMEData)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
QCBOREncode_AddTag(pMe, CBOR_TAG_BINARY_MIME);
@@ -3601,8 +3523,8 @@
static inline void
QCBOREncode_AddTMIMEDataToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC MIMEData)
+ const uint8_t uTagRequirement,
+ const UsefulBufC MIMEData)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddTMIMEData(pMe, uTagRequirement, MIMEData);
@@ -3610,9 +3532,9 @@
static inline void
QCBOREncode_AddTMIMEDataToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC MIMEData)
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBufC MIMEData)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddTMIMEData(pMe, uTagRequirement, MIMEData);
@@ -3627,15 +3549,15 @@
static inline void
QCBOREncode_AddMIMEDataToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC MIMEData)
+ const UsefulBufC MIMEData)
{
QCBOREncode_AddTMIMEDataToMapSZ(pMe, szLabel, QCBOR_ENCODE_AS_TAG, MIMEData);
}
static inline void
QCBOREncode_AddMIMEDataToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC MIMEData)
+ const int64_t nLabel,
+ const UsefulBufC MIMEData)
{
QCBOREncode_AddTMIMEDataToMapN(pMe, nLabel, QCBOR_ENCODE_AS_TAG, MIMEData);
}
@@ -3643,7 +3565,7 @@
static inline void
QCBOREncode_AddTDateString(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
const char *szDate)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
@@ -3655,7 +3577,7 @@
static inline void
QCBOREncode_AddTDateStringToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
const char *szDate)
{
QCBOREncode_AddSZString(pMe, szLabel);
@@ -3664,8 +3586,8 @@
static inline void
QCBOREncode_AddTDateStringToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
const char *szDate)
{
QCBOREncode_AddInt64(pMe, nLabel);
@@ -3688,7 +3610,7 @@
static inline void
QCBOREncode_AddDateStringToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
const char *szDate)
{
QCBOREncode_AddTDateStringToMapN(pMe, nLabel, QCBOR_ENCODE_AS_TAG, szDate);
@@ -3697,7 +3619,7 @@
static inline void
QCBOREncode_AddTDaysString(QCBOREncodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
const char *szDate)
{
if(uTagRequirement == QCBOR_ENCODE_AS_TAG) {
@@ -3709,7 +3631,7 @@
static inline void
QCBOREncode_AddTDaysStringToMapSZ(QCBOREncodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
const char *szDate)
{
QCBOREncode_AddSZString(pMe, szLabel);
@@ -3718,8 +3640,8 @@
static inline void
QCBOREncode_AddTDaysStringToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
const char *szDate)
{
QCBOREncode_AddInt64(pMe, nLabel);
@@ -3729,49 +3651,49 @@
static inline void
-QCBOREncode_AddSimple(QCBOREncodeContext *pMe, uint64_t uNum)
+QCBOREncode_Private_AddSimple(QCBOREncodeContext *pMe, const uint64_t uNum)
{
- QCBOREncode_AddType7(pMe, 0, uNum);
+ QCBOREncode_Private_AddType7(pMe, 0, uNum);
}
static inline void
-QCBOREncode_AddSimpleToMap(QCBOREncodeContext *pMe,
- const char *szLabel,
- uint8_t uSimple)
+QCBOREncode_Private_AddSimpleToMap(QCBOREncodeContext *pMe,
+ const char *szLabel,
+ const uint8_t uSimple)
{
QCBOREncode_AddSZString(pMe, szLabel);
- QCBOREncode_AddSimple(pMe, uSimple);
+ QCBOREncode_Private_AddSimple(pMe, uSimple);
}
static inline void
-QCBOREncode_AddSimpleToMapN(QCBOREncodeContext *pMe,
- int nLabel,
- uint8_t uSimple)
+QCBOREncode_Private_AddSimpleToMapN(QCBOREncodeContext *pMe,
+ const int64_t nLabel,
+ const uint8_t uSimple)
{
QCBOREncode_AddInt64(pMe, nLabel);
- QCBOREncode_AddSimple(pMe, uSimple);
+ QCBOREncode_Private_AddSimple(pMe, uSimple);
}
static inline void
-QCBOREncode_AddBool(QCBOREncodeContext *pMe, bool b)
+QCBOREncode_AddBool(QCBOREncodeContext *pMe, const bool b)
{
uint8_t uSimple = CBOR_SIMPLEV_FALSE;
if(b) {
uSimple = CBOR_SIMPLEV_TRUE;
}
- QCBOREncode_AddSimple(pMe, uSimple);
+ QCBOREncode_Private_AddSimple(pMe, uSimple);
}
static inline void
-QCBOREncode_AddBoolToMap(QCBOREncodeContext *pMe, const char *szLabel, bool b)
+QCBOREncode_AddBoolToMap(QCBOREncodeContext *pMe, const char *szLabel, const bool b)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddBool(pMe, b);
}
static inline void
-QCBOREncode_AddBoolToMapN(QCBOREncodeContext *pMe, int64_t nLabel, bool b)
+QCBOREncode_AddBoolToMapN(QCBOREncodeContext *pMe, const int64_t nLabel, const bool b)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddBool(pMe, b);
@@ -3781,7 +3703,7 @@
static inline void
QCBOREncode_AddNULL(QCBOREncodeContext *pMe)
{
- QCBOREncode_AddSimple(pMe, CBOR_SIMPLEV_NULL);
+ QCBOREncode_Private_AddSimple(pMe, CBOR_SIMPLEV_NULL);
}
static inline void
@@ -3792,7 +3714,7 @@
}
static inline void
-QCBOREncode_AddNULLToMapN(QCBOREncodeContext *pMe, int64_t nLabel)
+QCBOREncode_AddNULLToMapN(QCBOREncodeContext *pMe, const int64_t nLabel)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddNULL(pMe);
@@ -3802,7 +3724,7 @@
static inline void
QCBOREncode_AddUndef(QCBOREncodeContext *pMe)
{
- QCBOREncode_AddSimple(pMe, CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_Private_AddSimple(pMe, CBOR_SIMPLEV_UNDEF);
}
static inline void
@@ -3813,7 +3735,7 @@
}
static inline void
-QCBOREncode_AddUndefToMapN(QCBOREncodeContext *pMe, int64_t nLabel)
+QCBOREncode_AddUndefToMapN(QCBOREncodeContext *pMe, const int64_t nLabel)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddUndef(pMe);
@@ -3823,7 +3745,7 @@
static inline void
QCBOREncode_OpenArray(QCBOREncodeContext *pMe)
{
- QCBOREncode_OpenMapOrArray(pMe, CBOR_MAJOR_TYPE_ARRAY);
+ QCBOREncode_Private_OpenMapOrArray(pMe, CBOR_MAJOR_TYPE_ARRAY);
}
static inline void
@@ -3834,7 +3756,7 @@
}
static inline void
-QCBOREncode_OpenArrayInMapN(QCBOREncodeContext *pMe, int64_t nLabel)
+QCBOREncode_OpenArrayInMapN(QCBOREncodeContext *pMe, const int64_t nLabel)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_OpenArray(pMe);
@@ -3843,14 +3765,14 @@
static inline void
QCBOREncode_CloseArray(QCBOREncodeContext *pMe)
{
- QCBOREncode_CloseMapOrArray(pMe, CBOR_MAJOR_TYPE_ARRAY);
+ QCBOREncode_Private_CloseMapOrArray(pMe, CBOR_MAJOR_TYPE_ARRAY);
}
static inline void
QCBOREncode_OpenMap(QCBOREncodeContext *pMe)
{
- QCBOREncode_OpenMapOrArray(pMe, CBOR_MAJOR_TYPE_MAP);
+ QCBOREncode_Private_OpenMapOrArray(pMe, CBOR_MAJOR_TYPE_MAP);
}
static inline void
@@ -3861,7 +3783,7 @@
}
static inline void
-QCBOREncode_OpenMapInMapN(QCBOREncodeContext *pMe, int64_t nLabel)
+QCBOREncode_OpenMapInMapN(QCBOREncodeContext *pMe, const int64_t nLabel)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_OpenMap(pMe);
@@ -3870,13 +3792,13 @@
static inline void
QCBOREncode_CloseMap(QCBOREncodeContext *pMe)
{
- QCBOREncode_CloseMapOrArray(pMe, CBOR_MAJOR_TYPE_MAP);
+ QCBOREncode_Private_CloseMapOrArray(pMe, CBOR_MAJOR_TYPE_MAP);
}
static inline void
QCBOREncode_OpenArrayIndefiniteLength(QCBOREncodeContext *pMe)
{
- QCBOREncode_OpenMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_ARRAY_INDEFINITE_LEN);
+ QCBOREncode_Private_OpenMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_ARRAY_INDEFINITE_LEN);
}
static inline void
@@ -3889,7 +3811,7 @@
static inline void
QCBOREncode_OpenArrayIndefiniteLengthInMapN(QCBOREncodeContext *pMe,
- int64_t nLabel)
+ const int64_t nLabel)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_OpenArrayIndefiniteLength(pMe);
@@ -3898,14 +3820,14 @@
static inline void
QCBOREncode_CloseArrayIndefiniteLength(QCBOREncodeContext *pMe)
{
- QCBOREncode_CloseMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_ARRAY_INDEFINITE_LEN);
+ QCBOREncode_Private_CloseMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_ARRAY_INDEFINITE_LEN);
}
static inline void
QCBOREncode_OpenMapIndefiniteLength(QCBOREncodeContext *pMe)
{
- QCBOREncode_OpenMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN);
+ QCBOREncode_Private_OpenMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN);
}
static inline void
@@ -3918,7 +3840,7 @@
static inline void
QCBOREncode_OpenMapIndefiniteLengthInMapN(QCBOREncodeContext *pMe,
- int64_t nLabel)
+ const int64_t nLabel)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_OpenMapIndefiniteLength(pMe);
@@ -3927,14 +3849,14 @@
static inline void
QCBOREncode_CloseMapIndefiniteLength(QCBOREncodeContext *pMe)
{
- QCBOREncode_CloseMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN);
+ QCBOREncode_Private_CloseMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN);
}
static inline void
QCBOREncode_BstrWrap(QCBOREncodeContext *pMe)
{
- QCBOREncode_OpenMapOrArray(pMe, CBOR_MAJOR_TYPE_BYTE_STRING);
+ QCBOREncode_Private_OpenMapOrArray(pMe, CBOR_MAJOR_TYPE_BYTE_STRING);
}
static inline void
@@ -3945,7 +3867,7 @@
}
static inline void
-QCBOREncode_BstrWrapInMapN(QCBOREncodeContext *pMe, int64_t nLabel)
+QCBOREncode_BstrWrapInMapN(QCBOREncodeContext *pMe, const int64_t nLabel)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_BstrWrap(pMe);
@@ -3959,15 +3881,15 @@
static inline void
-QCBOREncode_AddEncoded(QCBOREncodeContext *pMe, UsefulBufC Encoded)
+QCBOREncode_AddEncoded(QCBOREncodeContext *pMe, const UsefulBufC Encoded)
{
- QCBOREncode_AddBuffer(pMe, CBOR_MAJOR_NONE_TYPE_RAW, Encoded);
+ QCBOREncode_Private_AddBuffer(pMe, CBOR_MAJOR_NONE_TYPE_RAW, Encoded);
}
static inline void
QCBOREncode_AddEncodedToMap(QCBOREncodeContext *pMe,
const char *szLabel,
- UsefulBufC Encoded)
+ const UsefulBufC Encoded)
{
QCBOREncode_AddSZString(pMe, szLabel);
QCBOREncode_AddEncoded(pMe, Encoded);
@@ -3975,8 +3897,8 @@
static inline void
QCBOREncode_AddEncodedToMapN(QCBOREncodeContext *pMe,
- int64_t nLabel,
- UsefulBufC Encoded)
+ const int64_t nLabel,
+ const UsefulBufC Encoded)
{
QCBOREncode_AddInt64(pMe, nLabel);
QCBOREncode_AddEncoded(pMe, Encoded);
diff --git a/inc/qcbor/qcbor_spiffy_decode.h b/inc/qcbor/qcbor_spiffy_decode.h
index 7423140..d8fc5e3 100644
--- a/inc/qcbor/qcbor_spiffy_decode.h
+++ b/inc/qcbor/qcbor_spiffy_decode.h
@@ -1,7 +1,7 @@
/* ==========================================================================
* qcbor_spiffy_decode.h -- higher-level easier-to-use CBOR decoding.
*
- * Copyright (c) 2020-2023, Laurence Lundblade. All rights reserved.
+ * Copyright (c) 2020-2024, Laurence Lundblade. All rights reserved.
* Copyright (c) 2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -1839,47 +1839,164 @@
========================================================================== */
-// Semi-private
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
void
-QCBORDecode_GetUInt64ConvertInternal(QCBORDecodeContext *pMe,
+QCBORDecode_Private_GetUInt64Convert(QCBORDecodeContext *pCtx,
uint32_t uConvertTypes,
uint64_t *puValue,
QCBORItem *pItem);
-// Semi-private
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
void
-QCBORDecode_GetUInt64ConvertInternalInMapN(QCBORDecodeContext *pMe,
+QCBORDecode_Private_GetUInt64ConvertInMapN(QCBORDecodeContext *pCtx,
int64_t nLabel,
uint32_t uConvertTypes,
uint64_t *puValue,
QCBORItem *pItem);
-// Semi-private
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
void
-QCBORDecode_GetUInt64ConvertInternalInMapSZ(QCBORDecodeContext *pMe,
+QCBORDecode_Private_GetUInt64ConvertInMapSZ(QCBORDecodeContext *pCtx,
const char *szLabel,
uint32_t uConvertTypes,
uint64_t *puValue,
QCBORItem *pItem);
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_EnterBoundedMapOrArray(QCBORDecodeContext *pCtx,
+ uint8_t uType,
+ QCBORItem *pItem);
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_ExitBoundedMapOrArray(QCBORDecodeContext *pCtx,
+ uint8_t uType);
+
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetInt64Convert(QCBORDecodeContext *pCtx,
+ uint32_t uConvertTypes,
+ int64_t *pnValue,
+ QCBORItem *pItem);
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetInt64ConvertInMapN(QCBORDecodeContext *pCtx,
+ int64_t nLabel,
+ uint32_t uConvertTypes,
+ int64_t *pnValue,
+ QCBORItem *pItem);
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetInt64ConvertInMapSZ(QCBORDecodeContext *pCtx,
+ const char *szLabel,
+ uint32_t uConvertTypes,
+ int64_t *pnValue,
+ QCBORItem *pItem);
+
+
+#ifndef USEFULBUF_DISABLE_ALL_FLOAT
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetDoubleConvert(QCBORDecodeContext *pCtx,
+ uint32_t uConvertTypes,
+ double *pValue,
+ QCBORItem *pItem);
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetDoubleConvertInMapN(QCBORDecodeContext *pCtx,
+ int64_t nLabel,
+ uint32_t uConvertTypes,
+ double *pdValue,
+ QCBORItem *pItem);
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetDoubleConvertInMapSZ(QCBORDecodeContext *pCtx,
+ const char *szLabel,
+ uint32_t uConvertTypes,
+ double *pdValue,
+ QCBORItem *pItem);
+#endif /* !USEFULBUF_DISABLE_ALL_FLOAT */
+
+#define QCBOR_TAGSPEC_NUM_TYPES 4
+/* Semi-private data structure (which might change).
+ *
+ * See QCBOR_Private_CheckTagRequirement() which uses this to check the
+ * type of a item to be decoded as a tag or tag content.
+ *
+ * Improvement: Carefully understand what compilers do with this,
+ * particularly initialization and see if it can be optimized so there
+ * is less code and maybe so it can be smaller.
+ */
+typedef struct {
+ /* One of QCBOR_TAGSPEC_MATCH_xxx */
+ uint8_t uTagRequirement;
+ /* The tagged type translated into QCBOR_TYPE_XXX. Used to match
+ * explicit tagging */
+ uint8_t uTaggedTypes[QCBOR_TAGSPEC_NUM_TYPES];
+ /* The types of the content, which are used to match implicit
+ * tagging */
+ uint8_t uAllowedContentTypes[QCBOR_TAGSPEC_NUM_TYPES];
+} QCBOR_Private_TagSpec;
+
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetTaggedString(QCBORDecodeContext *pCtx,
+ QCBOR_Private_TagSpec TagSpec,
+ UsefulBufC *pBstr);
+
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetTaggedStringInMapN(QCBORDecodeContext *pCtx,
+ int64_t nLabel,
+ QCBOR_Private_TagSpec TagSpec,
+ UsefulBufC *pString);
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+void
+QCBORDecode_Private_GetTaggedStringInMapSZ(QCBORDecodeContext *pCtx,
+ const char *szLabel,
+ QCBOR_Private_TagSpec TagSpec,
+ UsefulBufC *pString);
+
+
+/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
+QCBORError
+QCBORDecode_Private_GetMIME(uint8_t uTagRequirement,
+ const QCBORItem *pItem,
+ UsefulBufC *pMessage,
+ bool *pbIsTag257);
+
+
+
+
static inline void
QCBORDecode_GetUInt64Convert(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
+ const uint32_t uConvertTypes,
uint64_t *puValue)
{
QCBORItem Item;
- QCBORDecode_GetUInt64ConvertInternal(pMe, uConvertTypes, puValue, &Item);
+ QCBORDecode_Private_GetUInt64Convert(pMe, uConvertTypes, puValue, &Item);
}
static inline void
QCBORDecode_GetUInt64ConvertInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
+ const int64_t nLabel,
+ const uint32_t uConvertTypes,
uint64_t *puValue)
{
QCBORItem Item;
- QCBORDecode_GetUInt64ConvertInternalInMapN(pMe,
+ QCBORDecode_Private_GetUInt64ConvertInMapN(pMe,
nLabel,
uConvertTypes,
puValue,
@@ -1889,11 +2006,11 @@
static inline void
QCBORDecode_GetUInt64ConvertInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint32_t uConvertTypes,
+ const uint32_t uConvertTypes,
uint64_t *puValue)
{
QCBORItem Item;
- QCBORDecode_GetUInt64ConvertInternalInMapSZ(pMe,
+ QCBORDecode_Private_GetUInt64ConvertInMapSZ(pMe,
szLabel,
uConvertTypes,
puValue,
@@ -1908,7 +2025,7 @@
static inline void
QCBORDecode_GetUInt64InMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
uint64_t *puValue)
{
QCBORDecode_GetUInt64ConvertInMapN(pMe,
@@ -1929,81 +2046,48 @@
}
-// Semi-private
-void QCBORDecode_EnterBoundedMapOrArray(QCBORDecodeContext *pMe,
- uint8_t uType,
- QCBORItem *pItem);
-
-// Semi-private
static inline void
QCBORDecode_EnterMap(QCBORDecodeContext *pMe, QCBORItem *pItem) {
- QCBORDecode_EnterBoundedMapOrArray(pMe, QCBOR_TYPE_MAP, pItem);
+ QCBORDecode_Private_EnterBoundedMapOrArray(pMe, QCBOR_TYPE_MAP, pItem);
}
-// Semi-private
static inline void
QCBORDecode_EnterArray(QCBORDecodeContext *pMe, QCBORItem *pItem) {
- QCBORDecode_EnterBoundedMapOrArray(pMe, QCBOR_TYPE_ARRAY, pItem);
+ QCBORDecode_Private_EnterBoundedMapOrArray(pMe, QCBOR_TYPE_ARRAY, pItem);
}
-// Semi-private
-void
-QCBORDecode_ExitBoundedMapOrArray(QCBORDecodeContext *pMe, uint8_t uType);
-
static inline void
QCBORDecode_ExitArray(QCBORDecodeContext *pMe)
{
- QCBORDecode_ExitBoundedMapOrArray(pMe, QCBOR_TYPE_ARRAY);
+ QCBORDecode_Private_ExitBoundedMapOrArray(pMe, QCBOR_TYPE_ARRAY);
}
static inline void
QCBORDecode_ExitMap(QCBORDecodeContext *pMe)
{
- QCBORDecode_ExitBoundedMapOrArray(pMe, QCBOR_TYPE_MAP);
+ QCBORDecode_Private_ExitBoundedMapOrArray(pMe, QCBOR_TYPE_MAP);
}
-// Semi-private
-void
-QCBORDecode_GetInt64ConvertInternal(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
- int64_t *pnValue,
- QCBORItem *pItem);
-
-// Semi-private
-void
-QCBORDecode_GetInt64ConvertInternalInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
- int64_t *pnValue,
- QCBORItem *pItem);
-
-// Semi-private
-void
-QCBORDecode_GetInt64ConvertInternalInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint32_t uConvertTypes,
- int64_t *pnValue,
- QCBORItem *pItem);
static inline void
QCBORDecode_GetInt64Convert(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
+ const uint32_t uConvertTypes,
int64_t *pnValue)
{
QCBORItem Item;
- QCBORDecode_GetInt64ConvertInternal(pMe, uConvertTypes, pnValue, &Item);
+ QCBORDecode_Private_GetInt64Convert(pMe, uConvertTypes, pnValue, &Item);
}
static inline void
QCBORDecode_GetInt64ConvertInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
+ const int64_t nLabel,
+ const uint32_t uConvertTypes,
int64_t *pnValue)
{
QCBORItem Item;
- QCBORDecode_GetInt64ConvertInternalInMapN(pMe,
+ QCBORDecode_Private_GetInt64ConvertInMapN(pMe,
nLabel,
uConvertTypes,
pnValue,
@@ -2013,11 +2097,11 @@
static inline void
QCBORDecode_GetInt64ConvertInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint32_t uConvertTypes,
+ const uint32_t uConvertTypes,
int64_t *pnValue)
{
QCBORItem Item;
- QCBORDecode_GetInt64ConvertInternalInMapSZ(pMe,
+ QCBORDecode_Private_GetInt64ConvertInMapSZ(pMe,
szLabel,
uConvertTypes,
pnValue,
@@ -2032,7 +2116,7 @@
static inline void
QCBORDecode_GetInt64InMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
int64_t *pnValue)
{
QCBORDecode_GetInt64ConvertInMapN(pMe,
@@ -2057,47 +2141,23 @@
#ifndef USEFULBUF_DISABLE_ALL_FLOAT
-// Semi-private
-void
-QCBORDecode_GetDoubleConvertInternal(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
- double *pValue,
- QCBORItem *pItem);
-
-// Semi-private
-void
-QCBORDecode_GetDoubleConvertInternalInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
- double *pdValue,
- QCBORItem *pItem);
-
-// Semi-private
-void
-QCBORDecode_GetDoubleConvertInternalInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint32_t uConvertTypes,
- double *pdValue,
- QCBORItem *pItem);
-
-
static inline void
QCBORDecode_GetDoubleConvert(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
+ const uint32_t uConvertTypes,
double *pdValue)
{
QCBORItem Item;
- QCBORDecode_GetDoubleConvertInternal(pMe, uConvertTypes, pdValue, &Item);
+ QCBORDecode_Private_GetDoubleConvert(pMe, uConvertTypes, pdValue, &Item);
}
static inline void
QCBORDecode_GetDoubleConvertInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
uint32_t uConvertTypes,
double *pdValue)
{
QCBORItem Item;
- QCBORDecode_GetDoubleConvertInternalInMapN(pMe,
+ QCBORDecode_Private_GetDoubleConvertInMapN(pMe,
nLabel,
uConvertTypes,
pdValue,
@@ -2107,11 +2167,11 @@
static inline void
QCBORDecode_GetDoubleConvertInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint32_t uConvertTypes,
+ const uint32_t uConvertTypes,
double *pdValue)
{
QCBORItem Item;
- QCBORDecode_GetDoubleConvertInternalInMapSZ(pMe,
+ QCBORDecode_Private_GetDoubleConvertInMapSZ(pMe,
szLabel,
uConvertTypes,
pdValue,
@@ -2126,7 +2186,7 @@
static inline void
QCBORDecode_GetDoubleInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
double *pdValue)
{
QCBORDecode_GetDoubleConvertInMapN(pMe,
@@ -2149,85 +2209,34 @@
-#define QCBOR_TAGSPEC_NUM_TYPES 4
-/* Semi-private data structure (which might change).
- *
- * See CheckTagRequirement() which uses this to check the type of a
- * item to be decoded as a tag or tag content.
- *
- * Improvement: Carefully understand what compilers do with this,
- * particularly initialization and see if it can be optimized so there
- * is less code and maybe so it can be smaller.
- */
-typedef struct {
- /* One of QCBOR_TAGSPEC_MATCH_xxx */
- uint8_t uTagRequirement;
- /* The tagged type translated into QCBOR_TYPE_XXX. Used to match
- * explicit tagging */
- uint8_t uTaggedTypes[QCBOR_TAGSPEC_NUM_TYPES];
- /* The types of the content, which are used to match implicit
- * tagging */
- uint8_t uAllowedContentTypes[QCBOR_TAGSPEC_NUM_TYPES];
-} TagSpecification;
-
-
-// Semi private
-void
-QCBORDecode_GetTaggedStringInternal(QCBORDecodeContext *pMe,
- TagSpecification TagSpec,
- UsefulBufC *pBstr);
-
-
-// Semi private
-void
-QCBORDecode_GetTaggedStringInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- TagSpecification TagSpec,
- UsefulBufC *pString);
-
-// Semi private
-void
-QCBORDecode_GetTaggedStringInMapSZ(QCBORDecodeContext *pMe,
- const char * szLabel,
- TagSpecification TagSpec,
- UsefulBufC *pString);
-
-
-// Semi private
-QCBORError
-QCBORDecode_GetMIMEInternal(uint8_t uTagRequirement,
- const QCBORItem *pItem,
- UsefulBufC *pMessage,
- bool *pbIsTag257);
-
static inline void
QCBORDecode_GetByteString(QCBORDecodeContext *pMe, UsefulBufC *pValue)
{
// Complier should make this just a 64-bit integer parameter
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
QCBOR_TAG_REQUIREMENT_NOT_A_TAG,
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pValue);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pValue);
}
static inline void
QCBORDecode_GetByteStringInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
UsefulBufC *pBstr)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
QCBOR_TAG_REQUIREMENT_NOT_A_TAG,
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pBstr);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pBstr);
}
static inline void
@@ -2235,14 +2244,14 @@
const char *szLabel,
UsefulBufC *pBstr)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
QCBOR_TAG_REQUIREMENT_NOT_A_TAG,
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pBstr);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pBstr);
}
@@ -2250,31 +2259,31 @@
QCBORDecode_GetTextString(QCBORDecodeContext *pMe, UsefulBufC *pValue)
{
// Complier should make this just 64-bit integer parameter
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
QCBOR_TAG_REQUIREMENT_NOT_A_TAG,
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pValue);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pValue);
}
static inline void
QCBORDecode_GetTextStringInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
+ const int64_t nLabel,
UsefulBufC *pText)
{
// This TagSpec only matches text strings; it also should optimize down
// to passing a 64-bit integer
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
QCBOR_TAG_REQUIREMENT_NOT_A_TAG,
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
}
static inline void
@@ -2282,14 +2291,14 @@
const char *szLabel,
UsefulBufC *pText)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
QCBOR_TAG_REQUIREMENT_NOT_A_TAG,
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
}
static inline void
@@ -2305,7 +2314,7 @@
static inline void
QCBORDecode_GetNullInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel)
+ const int64_t nLabel)
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_NULL, &Item);
@@ -2313,7 +2322,7 @@
static inline void
QCBORDecode_GetNullInMapSZ(QCBORDecodeContext *pMe,
- const char * szLabel)
+ const char *szLabel)
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_NULL, &Item);
@@ -2332,7 +2341,7 @@
static inline void
QCBORDecode_GetUndefinedInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel)
+ const int64_t nLabel)
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_UNDEF, &Item);
@@ -2340,7 +2349,7 @@
static inline void
QCBORDecode_GetUndefinedInMapSZ(QCBORDecodeContext *pMe,
- const char * szLabel)
+ const char *szLabel)
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_UNDEF, &Item);
@@ -2349,294 +2358,294 @@
static inline void
QCBORDecode_GetDateString(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pValue)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pValue);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pValue);
}
static inline void
QCBORDecode_GetDateStringInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
UsefulBufC *pText)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
}
static inline void
QCBORDecode_GetDateStringInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pText)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
}
static inline void
QCBORDecode_GetDaysString(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pValue)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DAYS_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pValue);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pValue);
}
static inline void
QCBORDecode_GetDaysStringInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
UsefulBufC *pText)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DAYS_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
}
static inline void
QCBORDecode_GetDaysStringInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pText)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DAYS_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
}
static inline void
QCBORDecode_GetURI(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_URI, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pUUID);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pUUID);
}
static inline void
QCBORDecode_GetURIInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_URI, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pUUID);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pUUID);
}
static inline void
QCBORDecode_GetURIInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_URI, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pUUID);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pUUID);
}
static inline void
QCBORDecode_GetB64(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BASE64, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pB64Text);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pB64Text);
}
static inline void
QCBORDecode_GetB64InMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BASE64, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pB64Text);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pB64Text);
}
static inline void
QCBORDecode_GetB64InMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BASE64, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pB64Text);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pB64Text);
}
static inline void
QCBORDecode_GetB64URL(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BASE64URL, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pB64Text);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pB64Text);
}
static inline void
QCBORDecode_GetB64URLInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BASE64URL, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pB64Text);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pB64Text);
}
static inline void
QCBORDecode_GetB64URLInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BASE64URL, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pB64Text);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pB64Text);
}
static inline void
QCBORDecode_GetRegex(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pRegex)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_REGEX, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pRegex);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pRegex);
}
static inline void
QCBORDecode_GetRegexInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
UsefulBufC *pRegex)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_REGEX, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pRegex);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pRegex);
}
static inline void
QCBORDecode_GetRegexInMapSZ(QCBORDecodeContext *pMe,
const char * szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pRegex)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_REGEX, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pRegex);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pRegex);
}
static inline void
QCBORDecode_GetMIMEMessage(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pMessage,
bool *pbIsTag257)
{
@@ -2652,7 +2661,7 @@
return;
}
- pMe->uLastError = (uint8_t)QCBORDecode_GetMIMEInternal(uTagRequirement,
+ pMe->uLastError = (uint8_t)QCBORDecode_Private_GetMIME(uTagRequirement,
&Item,
pMessage,
pbIsTag257);
@@ -2660,8 +2669,8 @@
static inline void
QCBORDecode_GetMIMEMessageInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
UsefulBufC *pMessage,
bool *pbIsTag257)
{
@@ -2669,7 +2678,7 @@
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
if(pMe->uLastError == QCBOR_SUCCESS) {
- pMe->uLastError = (uint8_t)QCBORDecode_GetMIMEInternal(uTagRequirement,
+ pMe->uLastError = (uint8_t)QCBORDecode_Private_GetMIME(uTagRequirement,
&Item,
pMessage,
pbIsTag257);
@@ -2679,7 +2688,7 @@
static inline void
QCBORDecode_GetMIMEMessageInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pMessage,
bool *pbIsTag257)
{
@@ -2687,7 +2696,7 @@
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
if(pMe->uLastError == QCBOR_SUCCESS) {
- pMe->uLastError = (uint8_t)QCBORDecode_GetMIMEInternal(uTagRequirement,
+ pMe->uLastError = (uint8_t)QCBORDecode_Private_GetMIME(uTagRequirement,
&Item,
pMessage,
pbIsTag257);
@@ -2697,49 +2706,49 @@
static inline void
QCBORDecode_GetBinaryUUID(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_UUID, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pUUID);
+ QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pUUID);
}
static inline void
QCBORDecode_GetBinaryUUIDInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_UUID, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pUUID);
+ QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pUUID);
}
static inline void
QCBORDecode_GetBinaryUUIDInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint8_t uTagRequirement,
+ const uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_UUID, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pUUID);
+ QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pUUID);
}
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 57aab97..693152f 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -1,6 +1,6 @@
/*==============================================================================
Copyright (c) 2016-2018, The Linux Foundation.
- Copyright (c) 2018-2023, Laurence Lundblade.
+ Copyright (c) 2018-2024, Laurence Lundblade.
Copyright (c) 2021, Arm Limited.
All rights reserved.
@@ -47,7 +47,7 @@
#if (defined(__GNUC__) && !defined(__clang__))
-/*
+/*
* This is how the -Wmaybe-uninitialized compiler warning is
* handled. It can’t be ignored because some version of gcc enable it
* with -Wall which is a common and useful gcc warning option. It also
@@ -90,7 +90,7 @@
* https://stackoverflow.com/questions/5080848/disable-gcc-may-be-used-uninitialized-on-a-particular-variable
*/
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#endif
+#endif
@@ -100,46 +100,92 @@
-static inline bool
-QCBORItem_IsMapOrArray(const QCBORItem *pMe)
+static bool
+QCBORItem_IsMapOrArray(const QCBORItem Item)
{
- const uint8_t uDataType = pMe->uDataType;
+ const uint8_t uDataType = Item.uDataType;
return uDataType == QCBOR_TYPE_MAP ||
uDataType == QCBOR_TYPE_ARRAY ||
uDataType == QCBOR_TYPE_MAP_AS_ARRAY;
}
-static inline bool
-QCBORItem_IsEmptyDefiniteLengthMapOrArray(const QCBORItem *pMe)
+static bool
+QCBORItem_IsEmptyDefiniteLengthMapOrArray(const QCBORItem Item)
{
- if(!QCBORItem_IsMapOrArray(pMe)){
+ if(!QCBORItem_IsMapOrArray(Item)){
return false;
}
- if(pMe->val.uCount != 0) {
+ if(Item.val.uCount != 0) {
return false;
}
return true;
}
-static inline bool
-QCBORItem_IsIndefiniteLengthMapOrArray(const QCBORItem *pMe)
+static bool
+QCBORItem_IsIndefiniteLengthMapOrArray(const QCBORItem Item)
{
#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
- if(!QCBORItem_IsMapOrArray(pMe)){
+ if(!QCBORItem_IsMapOrArray(Item)){
return false;
}
- if(pMe->val.uCount != QCBOR_COUNT_INDICATES_INDEFINITE_LENGTH) {
+ if(Item.val.uCount != QCBOR_COUNT_INDICATES_INDEFINITE_LENGTH) {
return false;
}
return true;
#else /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
- (void)pMe;
+ (void)Item;
return false;
#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
}
+/* Return true if the labels in Item1 and Item2 are the same.
+ Works only for integer and string labels. Returns false
+ for any other type. */
+static bool
+QCBORItem_MatchLabel(const QCBORItem Item1, const QCBORItem Item2)
+{
+ if(Item1.uLabelType == QCBOR_TYPE_INT64) {
+ if(Item2.uLabelType == QCBOR_TYPE_INT64 && Item1.label.int64 == Item2.label.int64) {
+ return true;
+ }
+ } else if(Item1.uLabelType == QCBOR_TYPE_TEXT_STRING) {
+ if(Item2.uLabelType == QCBOR_TYPE_TEXT_STRING && !UsefulBuf_Compare(Item1.label.string, Item2.label.string)) {
+ return true;
+ }
+ } else if(Item1.uLabelType == QCBOR_TYPE_BYTE_STRING) {
+ if(Item2.uLabelType == QCBOR_TYPE_BYTE_STRING && !UsefulBuf_Compare(Item1.label.string, Item2.label.string)) {
+ return true;
+ }
+ } else if(Item1.uLabelType == QCBOR_TYPE_UINT64) {
+ if(Item2.uLabelType == QCBOR_TYPE_UINT64 && Item1.label.uint64 == Item2.label.uint64) {
+ return true;
+ }
+ }
+
+ /* Other label types are never matched */
+ return false;
+}
+
+
+/*
+ Returns true if Item1 and Item2 are the same type
+ or if either are of QCBOR_TYPE_ANY.
+ */
+static bool
+QCBORItem_MatchType(const QCBORItem Item1, const QCBORItem Item2)
+{
+ if(Item1.uDataType == Item2.uDataType) {
+ return true;
+ } else if(Item1.uDataType == QCBOR_TYPE_ANY) {
+ return true;
+ } else if(Item2.uDataType == QCBOR_TYPE_ANY) {
+ return true;
+ }
+ return false;
+}
+
/*===========================================================================
DecodeNesting -- Tracking array/map/sequence/bstr-wrapped nesting
@@ -151,7 +197,7 @@
*/
-static inline uint8_t
+static uint8_t
DecodeNesting_GetCurrentLevel(const QCBORDecodeNesting *pNesting)
{
const ptrdiff_t nLevel = pNesting->pCurrent - &(pNesting->pLevels[0]);
@@ -162,7 +208,7 @@
}
-static inline uint8_t
+static uint8_t
DecodeNesting_GetBoundedModeLevel(const QCBORDecodeNesting *pNesting)
{
const ptrdiff_t nLevel = pNesting->pCurrentBounded - &(pNesting->pLevels[0]);
@@ -173,14 +219,14 @@
}
-static inline uint32_t
+static uint32_t
DecodeNesting_GetMapOrArrayStart(const QCBORDecodeNesting *pNesting)
{
return pNesting->pCurrentBounded->u.ma.uStartOffset;
}
-static inline bool
+static bool
DecodeNesting_IsBoundedEmpty(const QCBORDecodeNesting *pNesting)
{
if(pNesting->pCurrentBounded->u.ma.uCountCursor == QCBOR_COUNT_INDICATES_ZERO_LENGTH) {
@@ -191,7 +237,7 @@
}
-static inline bool
+static bool
DecodeNesting_IsCurrentAtTop(const QCBORDecodeNesting *pNesting)
{
if(pNesting->pCurrent == &(pNesting->pLevels[0])) {
@@ -202,7 +248,7 @@
}
-static inline bool
+static bool
DecodeNesting_IsCurrentDefiniteLength(const QCBORDecodeNesting *pNesting)
{
if(pNesting->pCurrent->uLevelType == QCBOR_TYPE_BYTE_STRING) {
@@ -222,7 +268,7 @@
return true;
}
-static inline bool
+static bool
DecodeNesting_IsCurrentBstrWrapped(const QCBORDecodeNesting *pNesting)
{
if(pNesting->pCurrent->uLevelType == QCBOR_TYPE_BYTE_STRING) {
@@ -233,7 +279,8 @@
}
-static inline bool DecodeNesting_IsCurrentBounded(const QCBORDecodeNesting *pNesting)
+static bool
+DecodeNesting_IsCurrentBounded(const QCBORDecodeNesting *pNesting)
{
if(pNesting->pCurrent->uLevelType == QCBOR_TYPE_BYTE_STRING) {
return true;
@@ -245,7 +292,8 @@
}
-static inline void DecodeNesting_SetMapOrArrayBoundedMode(QCBORDecodeNesting *pNesting, bool bIsEmpty, size_t uStart)
+static void
+DecodeNesting_SetMapOrArrayBoundedMode(QCBORDecodeNesting *pNesting, bool bIsEmpty, size_t uStart)
{
/* Should be only called on maps and arrays */
/*
@@ -261,13 +309,14 @@
}
-static inline void DecodeNesting_ClearBoundedMode(QCBORDecodeNesting *pNesting)
+static void
+DecodeNesting_ClearBoundedMode(QCBORDecodeNesting *pNesting)
{
pNesting->pCurrent->u.ma.uStartOffset = QCBOR_NON_BOUNDED_OFFSET;
}
-static inline bool
+static bool
DecodeNesting_IsAtEndOfBoundedLevel(const QCBORDecodeNesting *pNesting)
{
if(pNesting->pCurrentBounded == NULL) {
@@ -293,7 +342,7 @@
}
-static inline bool
+static bool
DecodeNesting_IsEndOfDefiniteLengthMapOrArray(const QCBORDecodeNesting *pNesting)
{
/* Must only be called on map / array */
@@ -305,7 +354,7 @@
}
-static inline bool
+static bool
DecodeNesting_IsCurrentTypeMap(const QCBORDecodeNesting *pNesting)
{
if(pNesting->pCurrent->uLevelType == CBOR_MAJOR_TYPE_MAP) {
@@ -316,7 +365,7 @@
}
-static inline bool
+static bool
DecodeNesting_IsBoundedType(const QCBORDecodeNesting *pNesting, uint8_t uType)
{
if(pNesting->pCurrentBounded == NULL) {
@@ -331,7 +380,7 @@
}
-static inline void
+static void
DecodeNesting_DecrementDefiniteLengthMapOrArrayCount(QCBORDecodeNesting *pNesting)
{
/* Only call on a definite-length array / map */
@@ -339,7 +388,7 @@
}
-static inline void
+static void
DecodeNesting_ReverseDecrement(QCBORDecodeNesting *pNesting)
{
/* Only call on a definite-length array / map */
@@ -347,7 +396,7 @@
}
-static inline void
+static void
DecodeNesting_Ascend(QCBORDecodeNesting *pNesting)
{
pNesting->pCurrent--;
@@ -371,7 +420,7 @@
}
-static inline QCBORError
+static QCBORError
DecodeNesting_EnterBoundedMapOrArray(QCBORDecodeNesting *pNesting,
bool bIsEmpty,
size_t uOffset)
@@ -399,7 +448,7 @@
}
-static inline QCBORError
+static QCBORError
DecodeNesting_DescendMapOrArray(QCBORDecodeNesting *pNesting,
uint8_t uQCBORType,
uint64_t uCount)
@@ -437,14 +486,14 @@
}
-static inline void
+static void
DecodeNesting_LevelUpCurrent(QCBORDecodeNesting *pNesting)
{
pNesting->pCurrent = pNesting->pCurrentBounded - 1;
}
-static inline void
+static void
DecodeNesting_LevelUpBounded(QCBORDecodeNesting *pNesting)
{
while(pNesting->pCurrentBounded != &(pNesting->pLevels[0])) {
@@ -456,14 +505,14 @@
}
-static inline void
+static void
DecodeNesting_SetCurrentToBoundedLevel(QCBORDecodeNesting *pNesting)
{
pNesting->pCurrent = pNesting->pCurrentBounded;
}
-static inline QCBORError
+static QCBORError
DecodeNesting_DescendIntoBstrWrapped(QCBORDecodeNesting *pNesting,
uint32_t uEndOffset,
uint32_t uStartOffset)
@@ -487,14 +536,14 @@
}
-static inline void
+static void
DecodeNesting_ZeroMapOrArrayCount(QCBORDecodeNesting *pNesting)
{
pNesting->pCurrent->u.ma.uCountCursor = 0;
}
-static inline void
+static void
DecodeNesting_ResetMapOrArrayCount(QCBORDecodeNesting *pNesting)
{
if(pNesting->pCurrent->u.ma.uCountCursor != QCBOR_COUNT_INDICATES_ZERO_LENGTH) {
@@ -503,7 +552,7 @@
}
-static inline void
+static void
DecodeNesting_Init(QCBORDecodeNesting *pNesting)
{
/* Assumes that *pNesting has been zero'd before this call. */
@@ -512,7 +561,7 @@
}
-static inline void
+static void
DecodeNesting_PrepareForMapSearch(QCBORDecodeNesting *pNesting,
QCBORDecodeNesting *pSave)
{
@@ -520,7 +569,7 @@
}
-static inline void
+static void
DecodeNesting_RestoreFromMapSearch(QCBORDecodeNesting *pNesting,
const QCBORDecodeNesting *pSave)
{
@@ -528,7 +577,7 @@
}
-static inline uint32_t
+static uint32_t
DecodeNesting_GetPreviousBoundedEnd(const QCBORDecodeNesting *pMe)
{
return pMe->pCurrentBounded->u.bs.uSavedEndOffset;
@@ -546,7 +595,7 @@
===========================================================================*/
-static inline void
+static void
StringAllocator_Free(const QCBORInternalAllocator *pMe, const void *pMem)
{
/* This cast to uintptr_t suppresses the "-Wcast-qual" warnings.
@@ -558,7 +607,7 @@
// StringAllocator_Reallocate called with pMem NULL is
// equal to StringAllocator_Allocate()
-static inline UsefulBuf
+static UsefulBuf
StringAllocator_Reallocate(const QCBORInternalAllocator *pMe,
const void *pMem,
size_t uSize)
@@ -567,13 +616,13 @@
return (pMe->pfAllocator)(pMe->pAllocateCxt, (void *)(uintptr_t)pMem, uSize);
}
-static inline UsefulBuf
+static UsefulBuf
StringAllocator_Allocate(const QCBORInternalAllocator *pMe, size_t uSize)
{
return (pMe->pfAllocator)(pMe->pAllocateCxt, NULL, uSize);
}
-static inline void
+static void
StringAllocator_Destruct(const QCBORInternalAllocator *pMe)
{
/* See comment in StringAllocator_Free() */
@@ -595,9 +644,10 @@
/*
* Public function, see header file
*/
-void QCBORDecode_Init(QCBORDecodeContext *pMe,
- UsefulBufC EncodedCBOR,
- QCBORDecodeMode nDecodeMode)
+void
+QCBORDecode_Init(QCBORDecodeContext *pMe,
+ UsefulBufC EncodedCBOR,
+ QCBORDecodeMode nDecodeMode)
{
memset(pMe, 0, sizeof(QCBORDecodeContext));
UsefulInputBuf_Init(&(pMe->InBuf), EncodedCBOR);
@@ -618,10 +668,11 @@
/*
* Public function, see header file
*/
-void QCBORDecode_SetUpAllocator(QCBORDecodeContext *pMe,
- QCBORStringAllocate pfAllocateFunction,
- void *pAllocateContext,
- bool bAllStrings)
+void
+QCBORDecode_SetUpAllocator(QCBORDecodeContext *pMe,
+ QCBORStringAllocate pfAllocateFunction,
+ void *pAllocateContext,
+ bool bAllStrings)
{
pMe->StringAllocator.pfAllocator = pfAllocateFunction;
pMe->StringAllocator.pAllocateCxt = pAllocateContext;
@@ -635,8 +686,9 @@
/*
* Deprecated public function, see header file
*/
-void QCBORDecode_SetCallerConfiguredTagList(QCBORDecodeContext *pMe,
- const QCBORTagListIn *pTagList)
+void
+QCBORDecode_SetCallerConfiguredTagList(QCBORDecodeContext *pMe,
+ const QCBORTagListIn *pTagList)
{
/* This does nothing now. It is retained for backwards compatibility */
(void)pMe;
@@ -728,11 +780,11 @@
* avoids integer promotions, can reduce code size and makes static
* analyzers happier.
*/
-static inline QCBORError
-DecodeHead(UsefulInputBuf *pUInBuf,
- int *pnMajorType,
- uint64_t *puArgument,
- int *pnAdditionalInfo)
+static QCBORError
+QCBOR_Private_DecodeHead(UsefulInputBuf *pUInBuf,
+ int *pnMajorType,
+ uint64_t *puArgument,
+ int *pnAdditionalInfo)
{
QCBORError uReturn;
@@ -804,8 +856,10 @@
* away from zero than positive. Stdint, as far as I can tell, uses
* two's compliment to represent negative integers.
*/
-static inline QCBORError
-DecodeInteger(int nMajorType, uint64_t uArgument, QCBORItem *pDecodedItem)
+static QCBORError
+QCBOR_Private_DecodeInteger(const int nMajorType,
+ const uint64_t uArgument,
+ QCBORItem *pDecodedItem)
{
QCBORError uReturn = QCBOR_SUCCESS;
@@ -883,8 +937,10 @@
* @retval QCBOR_ERR_BAD_TYPE_7
*/
-static inline QCBORError
-DecodeType7(int nAdditionalInfo, uint64_t uArgument, QCBORItem *pDecodedItem)
+static QCBORError
+QCBOR_Private_DecodeType7(const int nAdditionalInfo,
+ const uint64_t uArgument,
+ QCBORItem *pDecodedItem)
{
QCBORError uReturn = QCBOR_SUCCESS;
@@ -1001,11 +1057,11 @@
* pDecodedItem. If @c pAllocator is not NULL then memory for the
* string is allocated.
*/
-static inline QCBORError
-DecodeBytes(const QCBORInternalAllocator *pAllocator,
- uint64_t uStrLen,
- UsefulInputBuf *pUInBuf,
- QCBORItem *pDecodedItem)
+static QCBORError
+QCBOR_Private_DecodeBytes(const QCBORInternalAllocator *pAllocator,
+ const uint64_t uStrLen,
+ UsefulInputBuf *pUInBuf,
+ QCBORItem *pDecodedItem)
{
QCBORError uReturn = QCBOR_SUCCESS;
@@ -1065,7 +1121,8 @@
*
* This only works for the two string types.
*/
-static inline uint8_t ConvertStringMajorTypes(int nCBORMajorType)
+static uint8_t
+QCBOR_Private_ConvertStringMajorTypes(int nCBORMajorType)
{
#if CBOR_MAJOR_TYPE_BYTE_STRING + 4 != QCBOR_TYPE_BYTE_STRING
#error QCBOR_TYPE_BYTE_STRING no lined up with major type
@@ -1087,7 +1144,8 @@
*
* This only works for the two aggregate types.
*/
-static inline uint8_t ConvertArrayOrMapType(int nCBORMajorType)
+static uint8_t
+QCBORDecode_Private_ConvertArrayOrMapType(int nCBORMajorType)
{
#if QCBOR_TYPE_ARRAY != CBOR_MAJOR_TYPE_ARRAY
#error QCBOR_TYPE_ARRAY value not lined up with major type
@@ -1122,9 +1180,9 @@
* no combing of data items.
*/
static QCBORError
-DecodeAtomicDataItem(UsefulInputBuf *pUInBuf,
- QCBORItem *pDecodedItem,
- const QCBORInternalAllocator *pAllocator)
+QCBOR_Private_DecodeAtomicDataItem(UsefulInputBuf *pUInBuf,
+ QCBORItem *pDecodedItem,
+ const QCBORInternalAllocator *pAllocator)
{
QCBORError uReturn;
@@ -1139,7 +1197,7 @@
memset(pDecodedItem, 0, sizeof(QCBORItem));
- uReturn = DecodeHead(pUInBuf, &nMajorType, &uArgument, &nAdditionalInfo);
+ uReturn = QCBOR_Private_DecodeHead(pUInBuf, &nMajorType, &uArgument, &nAdditionalInfo);
if(uReturn) {
goto Done;
}
@@ -1153,17 +1211,17 @@
if(nAdditionalInfo == LEN_IS_INDEFINITE) {
uReturn = QCBOR_ERR_BAD_INT;
} else {
- uReturn = DecodeInteger(nMajorType, uArgument, pDecodedItem);
+ uReturn = QCBOR_Private_DecodeInteger(nMajorType, uArgument, pDecodedItem);
}
break;
case CBOR_MAJOR_TYPE_BYTE_STRING: /* Major type 2 */
case CBOR_MAJOR_TYPE_TEXT_STRING: /* Major type 3 */
- pDecodedItem->uDataType = ConvertStringMajorTypes(nMajorType);
+ pDecodedItem->uDataType = QCBOR_Private_ConvertStringMajorTypes(nMajorType);
if(nAdditionalInfo == LEN_IS_INDEFINITE) {
pDecodedItem->val.string = (UsefulBufC){NULL, QCBOR_STRING_LENGTH_INDEFINITE};
} else {
- uReturn = DecodeBytes(pAllocator, uArgument, pUInBuf, pDecodedItem);
+ uReturn = QCBOR_Private_DecodeBytes(pAllocator, uArgument, pUInBuf, pDecodedItem);
}
break;
@@ -1186,7 +1244,7 @@
/* cast OK because of check above */
pDecodedItem->val.uCount = (uint16_t)uArgument;
}
- pDecodedItem->uDataType = ConvertArrayOrMapType(nMajorType);
+ pDecodedItem->uDataType = QCBORDecode_Private_ConvertArrayOrMapType(nMajorType);
break;
case CBOR_MAJOR_TYPE_TAG: /* Major type 6, tag numbers */
@@ -1204,7 +1262,7 @@
case CBOR_MAJOR_TYPE_SIMPLE:
/* Major type 7: float, double, true, false, null... */
- uReturn = DecodeType7(nAdditionalInfo, uArgument, pDecodedItem);
+ uReturn = QCBOR_Private_DecodeType7(nAdditionalInfo, uArgument, pDecodedItem);
break;
default:
@@ -1246,8 +1304,9 @@
*
* Code Reviewers: THIS FUNCTION DOES A LITTLE POINTER MATH
*/
-static inline QCBORError
-QCBORDecode_GetNextFullString(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
+static QCBORError
+QCBORDecode_Private_GetNextFullString(QCBORDecodeContext *pMe,
+ QCBORItem *pDecodedItem)
{
/* Aproximate stack usage
* 64-bit 32-bit
@@ -1288,7 +1347,7 @@
#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
QCBORError uReturn;
- uReturn = DecodeAtomicDataItem(&(pMe->InBuf), pDecodedItem, pAllocatorForGetNext);
+ uReturn = QCBOR_Private_DecodeAtomicDataItem(&(pMe->InBuf), pDecodedItem, pAllocatorForGetNext);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
@@ -1322,7 +1381,7 @@
* be allocated. They are always copied in the the contiguous
* buffer allocated here.
*/
- uReturn = DecodeAtomicDataItem(&(pMe->InBuf), &StringChunkItem, NULL);
+ uReturn = QCBOR_Private_DecodeAtomicDataItem(&(pMe->InBuf), &StringChunkItem, NULL);
if(uReturn) {
break;
}
@@ -1359,7 +1418,7 @@
uReturn = QCBOR_ERR_STRING_ALLOCATE;
break;
}
-
+
/* Copy new string chunk to the end of accumulated string */
FullString = UsefulBuf_CopyOffset(NewMem, FullString.len, StringChunkItem.val.string);
}
@@ -1397,8 +1456,10 @@
*
* See also UnMapTagNumber() and @ref QCBORItem.
*/
-static inline QCBORError
-MapTagNumber(QCBORDecodeContext *pMe, uint64_t uUnMappedTag, uint16_t *puMappedTagNumer)
+static QCBORError
+QCBORDecode_Private_MapTagNumber(QCBORDecodeContext *pMe,
+ const uint64_t uUnMappedTag,
+ uint16_t *puMappedTagNumer)
{
if(uUnMappedTag > QCBOR_LAST_UNMAPPED_TAG) {
unsigned uTagMapIndex;
@@ -1439,7 +1500,8 @@
* This is the reverse of MapTagNumber()
*/
static uint64_t
-UnMapTagNumber(const QCBORDecodeContext *pMe, uint16_t uMappedTagNumber)
+QCBORDecode_Private_UnMapTagNumber(const QCBORDecodeContext *pMe,
+ const uint16_t uMappedTagNumber)
{
if(uMappedTagNumber <= QCBOR_LAST_UNMAPPED_TAG) {
return uMappedTagNumber;
@@ -1481,7 +1543,8 @@
* item are not tag numbers.
*/
static QCBORError
-QCBORDecode_GetNextTagNumber(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
+QCBORDecode_Private_GetNextTagNumber(QCBORDecodeContext *pMe,
+ QCBORItem *pDecodedItem)
{
#ifndef QCBOR_DISABLE_TAGS
/* Accummulate the tags from multiple items here and then copy them
@@ -1500,7 +1563,7 @@
/* Loop fetching data items until the item fetched is not a tag */
for(;;) {
- QCBORError uErr = QCBORDecode_GetNextFullString(pMe, pDecodedItem);
+ QCBORError uErr = QCBORDecode_Private_GetNextFullString(pMe, pDecodedItem);
if(uErr != QCBOR_SUCCESS) {
uReturn = uErr;
goto Done;
@@ -1532,7 +1595,7 @@
/* Map the tag */
uint16_t uMappedTagNumber = 0;
- uReturn = MapTagNumber(pMe, pDecodedItem->val.uTagV, &uMappedTagNumber);
+ uReturn = QCBORDecode_Private_MapTagNumber(pMe, pDecodedItem->val.uTagV, &uMappedTagNumber);
/* Continue even on error so as to consume all tags wrapping
* this data item so decoding can go on. If MapTagNumber()
* errors once it will continue to error.
@@ -1583,10 +1646,11 @@
* is treated like an array to allow caller to do their
* own label processing.
*/
-static inline QCBORError
-QCBORDecode_GetNextMapEntry(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
+static QCBORError
+QCBORDecode_Private_GetNextMapEntry(QCBORDecodeContext *pMe,
+ QCBORItem *pDecodedItem)
{
- QCBORError uReturn = QCBORDecode_GetNextTagNumber(pMe, pDecodedItem);
+ QCBORError uReturn = QCBORDecode_Private_GetNextTagNumber(pMe, pDecodedItem);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
@@ -1604,7 +1668,7 @@
* be the real data item.
*/
QCBORItem LabelItem = *pDecodedItem;
- uReturn = QCBORDecode_GetNextTagNumber(pMe, pDecodedItem);
+ uReturn = QCBORDecode_Private_GetNextTagNumber(pMe, pDecodedItem);
if(QCBORDecode_IsUnrecoverableError(uReturn)) {
goto Done;
}
@@ -1673,14 +1737,14 @@
* See if next item is a CBOR break. If it is, it is consumed,
* if not it is not consumed.
*/
-static inline QCBORError
-NextIsBreak(UsefulInputBuf *pUIB, bool *pbNextIsBreak)
+static QCBORError
+QCBOR_Private_NextIsBreak(UsefulInputBuf *pUIB, bool *pbNextIsBreak)
{
*pbNextIsBreak = false;
if(UsefulInputBuf_BytesUnconsumed(pUIB) != 0) {
QCBORItem Peek;
size_t uPeek = UsefulInputBuf_Tell(pUIB);
- QCBORError uReturn = DecodeAtomicDataItem(pUIB, &Peek, NULL);
+ QCBORError uReturn = QCBOR_Private_DecodeAtomicDataItem(pUIB, &Peek, NULL);
if(uReturn != QCBOR_SUCCESS) {
return uReturn;
}
@@ -1708,7 +1772,7 @@
* may in turn close out the above array/map...
*/
static QCBORError
-QCBORDecode_NestLevelAscender(QCBORDecodeContext *pMe, bool bMarkEnd)
+QCBORDecode_Private_NestLevelAscender(QCBORDecodeContext *pMe, bool bMarkEnd)
{
QCBORError uReturn;
@@ -1742,7 +1806,7 @@
/* Check for a break which is what ends indefinite-length arrays/maps */
bool bIsBreak = false;
- uReturn = NextIsBreak(&(pMe->InBuf), &bIsBreak);
+ uReturn = QCBOR_Private_NextIsBreak(&(pMe->InBuf), &bIsBreak);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
@@ -1822,7 +1886,8 @@
* top-level sequence and of bstr-wrapped CBOR by byte count.
*/
static QCBORError
-QCBORDecode_GetNextMapOrArray(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
+QCBORDecode_Private_GetNextMapOrArray(QCBORDecodeContext *pMe,
+ QCBORItem *pDecodedItem)
{
QCBORError uReturn;
/* ==== First: figure out if at the end of a traversal ==== */
@@ -1850,7 +1915,7 @@
}
/* ==== Next: not at the end, so get another item ==== */
- uReturn = QCBORDecode_GetNextMapEntry(pMe, pDecodedItem);
+ uReturn = QCBORDecode_Private_GetNextMapEntry(pMe, pDecodedItem);
if(QCBORDecode_IsUnrecoverableError(uReturn)) {
/* Error is so bad that traversal is not possible. */
goto Done;
@@ -1871,7 +1936,7 @@
/* ==== Next: Process the item for descent, ascent, decrement... ==== */
- if(QCBORItem_IsMapOrArray(pDecodedItem)) {
+ if(QCBORItem_IsMapOrArray(*pDecodedItem)) {
/* If the new item is a map or array, descend.
*
* Empty indefinite-length maps and arrays are descended into,
@@ -1896,9 +1961,9 @@
}
}
- if(!QCBORItem_IsMapOrArray(pDecodedItem) ||
- QCBORItem_IsEmptyDefiniteLengthMapOrArray(pDecodedItem) ||
- QCBORItem_IsIndefiniteLengthMapOrArray(pDecodedItem)) {
+ if(!QCBORItem_IsMapOrArray(*pDecodedItem) ||
+ QCBORItem_IsEmptyDefiniteLengthMapOrArray(*pDecodedItem) ||
+ QCBORItem_IsIndefiniteLengthMapOrArray(*pDecodedItem)) {
/* The following cases are handled here:
* - A non-aggregate item like an integer or string
* - An empty definite-length map or array
@@ -1911,7 +1976,7 @@
* to the top level.
*/
QCBORError uAscendErr;
- uAscendErr = QCBORDecode_NestLevelAscender(pMe, true);
+ uAscendErr = QCBORDecode_Private_NestLevelAscender(pMe, true);
if(uAscendErr != QCBOR_SUCCESS) {
/* This error is probably a traversal error and it overrides
* the non-traversal error.
@@ -1948,7 +2013,8 @@
* The 0th tag is discarded. \ref CBOR_TAG_INVALID16 is
* shifted into empty slot at the end of the tag list.
*/
-static inline void ShiftTags(QCBORItem *pDecodedItem)
+static void
+QCBOR_Private_ShiftTags(QCBORItem *pDecodedItem)
{
for(int i = 0; i < QCBOR_MAX_TAGS_PER_ITEM-1; i++) {
pDecodedItem->uTags[i] = pDecodedItem->uTags[i+1];
@@ -1976,7 +2042,8 @@
* This converts all the date formats into one format of an unsigned
* integer plus a floating-point fraction.
*/
-static QCBORError DecodeDateEpoch(QCBORItem *pDecodedItem)
+static QCBORError
+QCBOR_Private_DecodeDateEpoch(QCBORItem *pDecodedItem)
{
QCBORError uReturn = QCBOR_SUCCESS;
@@ -2079,7 +2146,8 @@
* This is much simpler than the other epoch date format because
* floating-porint is not allowed. This is mostly a simple type check.
*/
-static QCBORError DecodeDaysEpoch(QCBORItem *pDecodedItem)
+static QCBORError
+QCBOR_Private_DecodeDaysEpoch(QCBORItem *pDecodedItem)
{
QCBORError uReturn = QCBOR_SUCCESS;
@@ -2124,7 +2192,8 @@
* correctly and the correct error is returned.
*/
static QCBORError
-QCBORDecode_GetNextTagContent(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem);
+QCBORDecode_Private_GetNextTagContent(QCBORDecodeContext *pMe,
+ QCBORItem *pDecodedItem);
/**
@@ -2152,7 +2221,8 @@
* the caller will process it.
*/
static QCBORError
-QCBORDecode_MantissaAndExponent(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
+QCBORDecode_Private_ExpMantissa(QCBORDecodeContext *pMe,
+ QCBORItem *pDecodedItem)
{
QCBORError uReturn;
@@ -2171,7 +2241,7 @@
/* --- Get the exponent --- */
QCBORItem exponentItem;
- uReturn = QCBORDecode_GetNextMapOrArray(pMe, &exponentItem);
+ uReturn = QCBORDecode_Private_GetNextMapOrArray(pMe, &exponentItem);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
@@ -2196,7 +2266,7 @@
/* --- Get the mantissa --- */
QCBORItem mantissaItem;
- uReturn = QCBORDecode_GetNextTagContent(pMe, &mantissaItem);
+ uReturn = QCBORDecode_Private_GetNextTagContent(pMe, &mantissaItem);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
@@ -2259,7 +2329,8 @@
* f or ProcessTaggedString() because the RFC 7049 MIME type was
* incorreclty text-only.
*/
-static inline QCBORError DecodeMIME(QCBORItem *pDecodedItem)
+static QCBORError
+QCBOR_Private_DecodeMIME(QCBORItem *pDecodedItem)
{
if(pDecodedItem->uDataType == QCBOR_TYPE_TEXT_STRING) {
pDecodedItem->uDataType = QCBOR_TYPE_MIME;
@@ -2291,7 +2362,7 @@
#define IS_BYTE_STRING_BIT 0x80
#define QCBOR_TYPE_MASK ~IS_BYTE_STRING_BIT
-static const struct StringTagMapEntry StringTagMap[] = {
+static const struct StringTagMapEntry QCBOR_Private_StringTagMap[] = {
{CBOR_TAG_DATE_STRING, QCBOR_TYPE_DATE_STRING},
{CBOR_TAG_DAYS_STRING, QCBOR_TYPE_DAYS_STRING},
{CBOR_TAG_POS_BIGNUM, QCBOR_TYPE_POSBIGNUM | IS_BYTE_STRING_BIT},
@@ -2327,8 +2398,8 @@
* functionality, but it part of implementing as much of RFC 8949 as
* possible.
*/
-static inline QCBORError
-ProcessTaggedString(uint16_t uTag, QCBORItem *pDecodedItem)
+static QCBORError
+QCBOR_Private_ProcessTaggedString(uint16_t uTag, QCBORItem *pDecodedItem)
{
/* This only works on tags that were not mapped; no need for other yet */
if(uTag > QCBOR_LAST_UNMAPPED_TAG) {
@@ -2336,13 +2407,13 @@
}
unsigned uIndex;
- for(uIndex = 0; StringTagMap[uIndex].uTagNumber != CBOR_TAG_INVALID16; uIndex++) {
- if(StringTagMap[uIndex].uTagNumber == uTag) {
+ for(uIndex = 0; QCBOR_Private_StringTagMap[uIndex].uTagNumber != CBOR_TAG_INVALID16; uIndex++) {
+ if(QCBOR_Private_StringTagMap[uIndex].uTagNumber == uTag) {
break;
}
}
- const uint8_t uQCBORType = StringTagMap[uIndex].uQCBORtype;
+ const uint8_t uQCBORType = QCBOR_Private_StringTagMap[uIndex].uQCBORtype;
if(uQCBORType == QCBOR_TYPE_NONE) {
/* repurpose this error to mean not handled here */
return QCBOR_ERR_UNSUPPORTED;
@@ -2377,8 +2448,9 @@
6 possible outputs
*/
-static inline uint8_t
-MantissaExponentDataType(const uint16_t uTagToProcess, const QCBORItem *pDecodedItem)
+static uint8_t
+QCBOR_Private_ExpMantissaDataType(const uint16_t uTagToProcess,
+ const QCBORItem *pDecodedItem)
{
uint8_t uBase = uTagToProcess == CBOR_TAG_DECIMAL_FRACTION ?
QCBOR_TYPE_DECIMAL_FRACTION :
@@ -2405,11 +2477,12 @@
* quick pass through for items that are not tags.
*/
static QCBORError
-QCBORDecode_GetNextTagContent(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
+QCBORDecode_Private_GetNextTagContent(QCBORDecodeContext *pMe,
+ QCBORItem *pDecodedItem)
{
QCBORError uReturn;
- uReturn = QCBORDecode_GetNextMapOrArray(pMe, pDecodedItem);
+ uReturn = QCBORDecode_Private_GetNextMapOrArray(pMe, pDecodedItem);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
@@ -2435,28 +2508,28 @@
break;
} else if(uTagToProcess == CBOR_TAG_DATE_EPOCH) {
- uReturn = DecodeDateEpoch(pDecodedItem);
+ uReturn = QCBOR_Private_DecodeDateEpoch(pDecodedItem);
} else if(uTagToProcess == CBOR_TAG_DAYS_EPOCH) {
- uReturn = DecodeDaysEpoch(pDecodedItem);
+ uReturn = QCBOR_Private_DecodeDaysEpoch(pDecodedItem);
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
} else if(uTagToProcess == CBOR_TAG_DECIMAL_FRACTION ||
uTagToProcess == CBOR_TAG_BIGFLOAT) {
- uReturn = QCBORDecode_MantissaAndExponent(pMe, pDecodedItem);
+ uReturn = QCBORDecode_Private_ExpMantissa(pMe, pDecodedItem);
/* --- Which is it, decimal fraction or a bigfloat? --- */
- pDecodedItem->uDataType = MantissaExponentDataType(uTagToProcess, pDecodedItem);
+ pDecodedItem->uDataType = QCBOR_Private_ExpMantissaDataType(uTagToProcess, pDecodedItem);
#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
#ifndef QCBOR_DISABLE_UNCOMMON_TAGS
} else if(uTagToProcess == CBOR_TAG_MIME ||
uTagToProcess == CBOR_TAG_BINARY_MIME) {
- uReturn = DecodeMIME(pDecodedItem);
+ uReturn = QCBOR_Private_DecodeMIME(pDecodedItem);
#endif /* QCBOR_DISABLE_UNCOMMON_TAGS */
} else {
/* See if it is a passthrough byte/text string tag; process if so */
- uReturn = ProcessTaggedString(pDecodedItem->uTags[0], pDecodedItem);
+ uReturn = QCBOR_Private_ProcessTaggedString(pDecodedItem->uTags[0], pDecodedItem);
if(uReturn == QCBOR_ERR_UNSUPPORTED) {
/* It wasn't a passthrough byte/text string tag so it is
@@ -2476,7 +2549,7 @@
/* A tag was successfully processed, shift it out of the list of
* tags returned. This is the loop increment.
*/
- ShiftTags(pDecodedItem);
+ QCBOR_Private_ShiftTags(pDecodedItem);
}
#endif /* QCBOR_DISABLE_TAGS */
@@ -2492,7 +2565,7 @@
QCBORDecode_GetNext(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
{
QCBORError uErr;
- uErr = QCBORDecode_GetNextTagContent(pMe, pDecodedItem);
+ uErr = QCBORDecode_Private_GetNextTagContent(pMe, pDecodedItem);
if(uErr != QCBOR_SUCCESS) {
pDecodedItem->uDataType = QCBOR_TYPE_NONE;
pDecodedItem->uLabelType = QCBOR_TYPE_NONE;
@@ -2536,7 +2609,8 @@
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_VGetNext(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
+void
+QCBORDecode_VGetNext(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -2573,7 +2647,7 @@
if(pTags->uNumUsed >= pTags->uNumAllocated) {
return QCBOR_ERR_TOO_MANY_TAGS;
}
- pTags->puTags[pTags->uNumUsed] = UnMapTagNumber(pMe,pDecodedItem->uTags[nTagIndex]);
+ pTags->puTags[pTags->uNumUsed] = QCBORDecode_Private_UnMapTagNumber(pMe,pDecodedItem->uTags[nTagIndex]);
pTags->uNumUsed++;
}
}
@@ -2592,16 +2666,17 @@
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-bool QCBORDecode_IsTagged(QCBORDecodeContext *pMe,
- const QCBORItem *pItem,
- uint64_t uTag)
+bool
+QCBORDecode_IsTagged(QCBORDecodeContext *pMe,
+ const QCBORItem *pItem,
+ uint64_t uTag)
{
#ifndef QCBOR_DISABLE_TAGS
for(unsigned uTagIndex = 0; uTagIndex < QCBOR_MAX_TAGS_PER_ITEM; uTagIndex++) {
if(pItem->uTags[uTagIndex] == CBOR_TAG_INVALID16) {
break;
}
- if(UnMapTagNumber(pMe, pItem->uTags[uTagIndex]) == uTag) {
+ if(QCBORDecode_Private_UnMapTagNumber(pMe, pItem->uTags[uTagIndex]) == uTag) {
return true;
}
}
@@ -2618,7 +2693,8 @@
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-QCBORError QCBORDecode_PartialFinish(QCBORDecodeContext *pMe, size_t *puConsumed)
+QCBORError
+QCBORDecode_PartialFinish(QCBORDecodeContext *pMe, size_t *puConsumed)
{
if(puConsumed != NULL) {
*puConsumed = pMe->InBuf.cursor;
@@ -2649,7 +2725,8 @@
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-QCBORError QCBORDecode_Finish(QCBORDecodeContext *pMe)
+QCBORError
+QCBORDecode_Finish(QCBORDecodeContext *pMe)
{
#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS
/* Call the destructor for the string allocator if there is one.
@@ -2665,10 +2742,11 @@
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-// Improvement: make these inline?
-uint64_t QCBORDecode_GetNthTag(QCBORDecodeContext *pMe,
- const QCBORItem *pItem,
- uint32_t uIndex)
+// Improvement: make these inline? TODO:
+uint64_t
+QCBORDecode_GetNthTag(QCBORDecodeContext *pMe,
+ const QCBORItem *pItem,
+ uint32_t uIndex)
{
#ifndef QCBOR_DISABLE_TAGS
if(pItem->uDataType == QCBOR_TYPE_NONE) {
@@ -2677,7 +2755,7 @@
if(uIndex >= QCBOR_MAX_TAGS_PER_ITEM) {
return CBOR_TAG_INVALID64;
} else {
- return UnMapTagNumber(pMe, pItem->uTags[uIndex]);
+ return QCBORDecode_Private_UnMapTagNumber(pMe, pItem->uTags[uIndex]);
}
#else /* QCBOR_DISABLE_TAGS */
(void)pMe;
@@ -2692,8 +2770,9 @@
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-uint64_t QCBORDecode_GetNthTagOfLast(const QCBORDecodeContext *pMe,
- uint32_t uIndex)
+uint64_t
+QCBORDecode_GetNthTagOfLast(const QCBORDecodeContext *pMe,
+ uint32_t uIndex)
{
#ifndef QCBOR_DISABLE_TAGS
@@ -2703,7 +2782,7 @@
if(uIndex >= QCBOR_MAX_TAGS_PER_ITEM) {
return CBOR_TAG_INVALID64;
} else {
- return UnMapTagNumber(pMe, pMe->uLastTags[uIndex]);
+ return QCBORDecode_Private_UnMapTagNumber(pMe, pMe->uLastTags[uIndex]);
}
#else /* QCBOR_DISABLE_TAGS */
(void)pMe;
@@ -2745,7 +2824,7 @@
========================================================================== */
-static inline int
+static int
MemPool_Unpack(const void *pMem, uint32_t *puPoolSize, uint32_t *puFreeOffset)
{
// Use of UsefulInputBuf is overkill, but it is convenient.
@@ -2760,7 +2839,7 @@
}
-static inline int
+static int
MemPool_Pack(UsefulBuf Pool, uint32_t uFreeOffset)
{
// Use of UsefulOutBuf is overkill, but convenient. The
@@ -2867,9 +2946,10 @@
/*
Public function, see header qcbor/qcbor_decode.h file
*/
-QCBORError QCBORDecode_SetMemPool(QCBORDecodeContext *pMe,
- UsefulBuf Pool,
- bool bAllStrings)
+QCBORError
+QCBORDecode_SetMemPool(QCBORDecodeContext *pMe,
+ UsefulBuf Pool,
+ bool bAllStrings)
{
// The pool size and free mem offset are packed into the beginning
// of the pool memory. This compile time check makes sure the
@@ -2906,8 +2986,8 @@
-static inline void
-CopyTags(QCBORDecodeContext *pMe, const QCBORItem *pItem)
+static void
+QCBORDecode_Private_CopyTags(QCBORDecodeContext *pMe, const QCBORItem *pItem)
{
#ifndef QCBOR_DISABLE_TAGS
memcpy(pMe->uLastTags, pItem->uTags, sizeof(pItem->uTags));
@@ -2931,10 +3011,10 @@
* map. In that case, this is just a pass through for @c puNextNestLevel
* since there is nothing to do.
*/
-static inline QCBORError
-ConsumeItem(QCBORDecodeContext *pMe,
- const QCBORItem *pItemToConsume,
- uint8_t *puNextNestLevel)
+static QCBORError
+QCBORDecode_Private_ConsumeItem(QCBORDecodeContext *pMe,
+ const QCBORItem *pItemToConsume,
+ uint8_t *puNextNestLevel)
{
QCBORError uReturn;
QCBORItem Item;
@@ -2942,7 +3022,7 @@
/* If it is a map or array, this will tell if it is empty. */
const bool bIsEmpty = (pItemToConsume->uNextNestLevel <= pItemToConsume->uNestingLevel);
- if(QCBORItem_IsMapOrArray(pItemToConsume) && !bIsEmpty) {
+ if(QCBORItem_IsMapOrArray(*pItemToConsume) && !bIsEmpty) {
/* There is only real work to do for non-empty maps and arrays */
/* This works for definite- and indefinite-length maps and
@@ -2973,12 +3053,16 @@
}
-void QCBORDecode_VGetNextConsume(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
+/*
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_VGetNextConsume(QCBORDecodeContext *pMe, QCBORItem *pDecodedItem)
{
QCBORDecode_VGetNext(pMe, pDecodedItem);
if(pMe->uLastError == QCBOR_SUCCESS) {
- pMe->uLastError = (uint8_t)ConsumeItem(pMe, pDecodedItem,
+ pMe->uLastError = (uint8_t)QCBORDecode_Private_ConsumeItem(pMe, pDecodedItem,
&pDecodedItem->uNextNestLevel);
}
}
@@ -2988,7 +3072,8 @@
/* Call only on maps and arrays. Rewinds the cursor
* to the start as if it was just entered.
*/
-static void RewindMapOrArray(QCBORDecodeContext *pMe)
+static void
+QCBORDecode_Private_RewindMapOrArray(QCBORDecodeContext *pMe)
{
/* Reset nesting tracking to the deepest bounded level */
DecodeNesting_SetCurrentToBoundedLevel(&(pMe->nesting));
@@ -3002,9 +3087,10 @@
/*
- Public function, see header qcbor/qcbor_decode.h file
+ * Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_Rewind(QCBORDecodeContext *pMe)
+void
+QCBORDecode_Rewind(QCBORDecodeContext *pMe)
{
if(pMe->nesting.pCurrentBounded != NULL) {
/* In a bounded map, array or bstr-wrapped CBOR */
@@ -3019,7 +3105,7 @@
} else {
/* In a map or array */
- RewindMapOrArray(pMe);
+ QCBORDecode_Private_RewindMapOrArray(pMe);
}
} else {
@@ -3036,51 +3122,7 @@
}
-/* Return true if the labels in Item1 and Item2 are the same.
- Works only for integer and string labels. Returns false
- for any other type. */
-static inline bool
-MatchLabel(QCBORItem Item1, QCBORItem Item2)
-{
- if(Item1.uLabelType == QCBOR_TYPE_INT64) {
- if(Item2.uLabelType == QCBOR_TYPE_INT64 && Item1.label.int64 == Item2.label.int64) {
- return true;
- }
- } else if(Item1.uLabelType == QCBOR_TYPE_TEXT_STRING) {
- if(Item2.uLabelType == QCBOR_TYPE_TEXT_STRING && !UsefulBuf_Compare(Item1.label.string, Item2.label.string)) {
- return true;
- }
- } else if(Item1.uLabelType == QCBOR_TYPE_BYTE_STRING) {
- if(Item2.uLabelType == QCBOR_TYPE_BYTE_STRING && !UsefulBuf_Compare(Item1.label.string, Item2.label.string)) {
- return true;
- }
- } else if(Item1.uLabelType == QCBOR_TYPE_UINT64) {
- if(Item2.uLabelType == QCBOR_TYPE_UINT64 && Item1.label.uint64 == Item2.label.uint64) {
- return true;
- }
- }
- /* Other label types are never matched */
- return false;
-}
-
-
-/*
- Returns true if Item1 and Item2 are the same type
- or if either are of QCBOR_TYPE_ANY.
- */
-static inline bool
-MatchType(QCBORItem Item1, QCBORItem Item2)
-{
- if(Item1.uDataType == Item2.uDataType) {
- return true;
- } else if(Item1.uDataType == QCBOR_TYPE_ANY) {
- return true;
- } else if(Item2.uDataType == QCBOR_TYPE_ANY) {
- return true;
- }
- return false;
-}
/**
@@ -3116,11 +3158,11 @@
This also finds the ends of maps and arrays when they are exited.
*/
static QCBORError
-MapSearch(QCBORDecodeContext *pMe,
- QCBORItem *pItemArray,
- size_t *puOffset,
- void *pCBContext,
- QCBORItemCallback pfCallback)
+QCBORDecode_Private_MapSearch(QCBORDecodeContext *pMe,
+ QCBORItem *pItemArray,
+ size_t *puOffset,
+ void *pCBContext,
+ QCBORItemCallback pfCallback)
{
QCBORError uReturn;
uint64_t uFoundItemBitMap = 0;
@@ -3156,7 +3198,7 @@
DecodeNesting_PrepareForMapSearch(&(pMe->nesting), &SaveNesting);
/* Reposition to search from the start of the map / array */
- RewindMapOrArray(pMe);
+ QCBORDecode_Private_RewindMapOrArray(pMe);
/*
Loop over all the items in the map or array. Each item
@@ -3183,7 +3225,7 @@
/* Get the item */
QCBORItem Item;
- QCBORError uResult = QCBORDecode_GetNextTagContent(pMe, &Item);
+ QCBORError uResult = QCBORDecode_Private_GetNextTagContent(pMe, &Item);
if(QCBORDecode_IsUnrecoverableError(uResult)) {
/* Unrecoverable error so map can't even be decoded. */
uReturn = uResult;
@@ -3198,7 +3240,7 @@
/* See if item has one of the labels that are of interest */
bool bMatched = false;
for(int nIndex = 0; pItemArray[nIndex].uLabelType != QCBOR_TYPE_NONE; nIndex++) {
- if(MatchLabel(Item, pItemArray[nIndex])) {
+ if(QCBORItem_MatchLabel(Item, pItemArray[nIndex])) {
/* A label match has been found */
if(uFoundItemBitMap & (0x01ULL << nIndex)) {
uReturn = QCBOR_ERR_DUPLICATE_LABEL;
@@ -3209,7 +3251,7 @@
uReturn = uResult;
goto Done;
}
- if(!MatchType(Item, pItemArray[nIndex])) {
+ if(!QCBORItem_MatchType(Item, pItemArray[nIndex])) {
/* The data item is not of the type(s) requested */
uReturn = QCBOR_ERR_UNEXPECTED_TYPE;
goto Done;
@@ -3246,7 +3288,7 @@
items at the current nesting level are examined
to match the labels.
*/
- uReturn = ConsumeItem(pMe, &Item, &uNextNestLevel);
+ uReturn = QCBORDecode_Private_ConsumeItem(pMe, &Item, &uNextNestLevel);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
@@ -3284,12 +3326,13 @@
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetItemInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uQcborType,
- QCBORItem *pItem)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetItemInMapN(QCBORDecodeContext *pMe,
+ int64_t nLabel,
+ uint8_t uQcborType,
+ QCBORItem *pItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -3301,7 +3344,7 @@
OneItemSeach[0].uDataType = uQcborType;
OneItemSeach[1].uLabelType = QCBOR_TYPE_NONE; // Indicates end of array
- QCBORError uReturn = MapSearch(pMe, OneItemSeach, NULL, NULL, NULL);
+ QCBORError uReturn = QCBORDecode_Private_MapSearch(pMe, OneItemSeach, NULL, NULL, NULL);
*pItem = OneItemSeach[0];
@@ -3318,12 +3361,13 @@
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetItemInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint8_t uQcborType,
- QCBORItem *pItem)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetItemInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ uint8_t uQcborType,
+ QCBORItem *pItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -3335,7 +3379,7 @@
OneItemSeach[0].uDataType = uQcborType;
OneItemSeach[1].uLabelType = QCBOR_TYPE_NONE; // Indicates end of array
- QCBORError uReturn = MapSearch(pMe, OneItemSeach, NULL, NULL, NULL);
+ QCBORError uReturn = QCBORDecode_Private_MapSearch(pMe, OneItemSeach, NULL, NULL, NULL);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
@@ -3352,7 +3396,8 @@
static QCBORError
-CheckTypeList(int uDataType, const uint8_t puTypeList[QCBOR_TAGSPEC_NUM_TYPES])
+QCBOR_Private_CheckTypeList(const int uDataType,
+ const uint8_t puTypeList[QCBOR_TAGSPEC_NUM_TYPES])
{
for(size_t i = 0; i < QCBOR_TAGSPEC_NUM_TYPES; i++) {
if(uDataType == puTypeList[i]) { /* -Wmaybe-uninitialized falsly warns here */
@@ -3389,7 +3434,8 @@
* ever be fulfilled.
*/
static QCBORError
-CheckTagRequirement(const TagSpecification TagSpec, const QCBORItem *pItem)
+QCBOR_Private_CheckTagRequirement(const QCBOR_Private_TagSpec TagSpec,
+ const QCBORItem *pItem)
{
const int nItemType = pItem->uDataType; /* -Wmaybe-uninitialized falsly warns here */
const int nTagReq = TagSpec.uTagRequirement & ~QCBOR_TAG_REQUIREMENT_ALLOW_ADDITIONAL_TAGS;
@@ -3406,10 +3452,10 @@
if(nTagReq == QCBOR_TAG_REQUIREMENT_TAG) {
/* Must match the tag number and only the tag */
- return CheckTypeList(nItemType, TagSpec.uTaggedTypes);
+ return QCBOR_Private_CheckTypeList(nItemType, TagSpec.uTaggedTypes);
}
- QCBORError uReturn = CheckTypeList(nItemType, TagSpec.uAllowedContentTypes);
+ QCBORError uReturn = QCBOR_Private_CheckTypeList(nItemType, TagSpec.uAllowedContentTypes);
if(uReturn == QCBOR_SUCCESS) {
return QCBOR_SUCCESS;
}
@@ -3426,7 +3472,7 @@
* the tag optional case that the CBOR standard discourages.
*/
- return CheckTypeList(nItemType, TagSpec.uTaggedTypes);
+ return QCBOR_Private_CheckTypeList(nItemType, TagSpec.uTaggedTypes);
#else /* QCBOR_DISABLE_TAGS */
if(nTagReq == QCBOR_TAG_REQUIREMENT_TAG) {
@@ -3440,41 +3486,43 @@
// This could be semi-private if need be
-static inline
-void QCBORDecode_GetTaggedItemInMapN(QCBORDecodeContext *pMe,
- const int64_t nLabel,
- const TagSpecification TagSpec,
- QCBORItem *pItem)
+// TODO: decide what to do
+static void
+QCBORDecode_GetTaggedItemInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const QCBOR_Private_TagSpec TagSpec,
+ QCBORItem *pItem)
{
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, pItem);
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
}
- pMe->uLastError = (uint8_t)CheckTagRequirement(TagSpec, pItem);
+ pMe->uLastError = (uint8_t)QCBOR_Private_CheckTagRequirement(TagSpec, pItem);
}
// This could be semi-private if need be
-static inline
-void QCBORDecode_GetTaggedItemInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- const TagSpecification TagSpec,
- QCBORItem *pItem)
+static void
+QCBORDecode_GetTaggedItemInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const QCBOR_Private_TagSpec TagSpec,
+ QCBORItem *pItem)
{
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, pItem);
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
}
- pMe->uLastError = (uint8_t)CheckTagRequirement(TagSpec, pItem);
+ pMe->uLastError = (uint8_t)QCBOR_Private_CheckTagRequirement(TagSpec, pItem);
}
// Semi-private
-void QCBORDecode_GetTaggedStringInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- TagSpecification TagSpec,
- UsefulBufC *pString)
+void
+QCBORDecode_Private_GetTaggedStringInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const QCBOR_Private_TagSpec TagSpec,
+ UsefulBufC *pString)
{
QCBORItem Item;
QCBORDecode_GetTaggedItemInMapN(pMe, nLabel, TagSpec, &Item);
@@ -3484,10 +3532,11 @@
}
// Semi-private
-void QCBORDecode_GetTaggedStringInMapSZ(QCBORDecodeContext *pMe,
- const char * szLabel,
- TagSpecification TagSpec,
- UsefulBufC *pString)
+void
+QCBORDecode_Private_GetTaggedStringInMapSZ(QCBORDecodeContext *pMe,
+ const char * szLabel,
+ const QCBOR_Private_TagSpec TagSpec,
+ UsefulBufC *pString)
{
QCBORItem Item;
QCBORDecode_GetTaggedItemInMapSZ(pMe, szLabel, TagSpec, &Item);
@@ -3497,23 +3546,25 @@
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetItemsInMap(QCBORDecodeContext *pMe, QCBORItem *pItemList)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetItemsInMap(QCBORDecodeContext *pMe, QCBORItem *pItemList)
{
- QCBORError uErr = MapSearch(pMe, pItemList, NULL, NULL, NULL);
+ QCBORError uErr = QCBORDecode_Private_MapSearch(pMe, pItemList, NULL, NULL, NULL);
pMe->uLastError = (uint8_t)uErr;
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetItemsInMapWithCallback(QCBORDecodeContext *pMe,
- QCBORItem *pItemList,
- void *pCallbackCtx,
- QCBORItemCallback pfCB)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetItemsInMapWithCallback(QCBORDecodeContext *pMe,
+ QCBORItem *pItemList,
+ void *pCallbackCtx,
+ QCBORItemCallback pfCB)
{
- QCBORError uErr = MapSearch(pMe, pItemList, NULL, pCallbackCtx, pfCB);
+ QCBORError uErr = QCBORDecode_Private_MapSearch(pMe, pItemList, NULL, pCallbackCtx, pfCB);
pMe->uLastError = (uint8_t)uErr;
}
@@ -3531,7 +3582,8 @@
* If the label is not found, or the item found is not a map or array,
* the error state is set.
*/
-static void SearchAndEnter(QCBORDecodeContext *pMe, QCBORItem pSearch[])
+static void
+QCBORDecode_Private_SearchAndEnter(QCBORDecodeContext *pMe, QCBORItem pSearch[])
{
// The first item in pSearch is the one that is to be
// entered. It should be the only one filled in. Any other
@@ -3541,7 +3593,7 @@
}
size_t uOffset;
- pMe->uLastError = (uint8_t)MapSearch(pMe, pSearch, &uOffset, NULL, NULL);
+ pMe->uLastError = (uint8_t)QCBORDecode_Private_MapSearch(pMe, pSearch, &uOffset, NULL, NULL);
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
}
@@ -3577,14 +3629,15 @@
DecodeNesting_SetCurrentToBoundedLevel(&(pMe->nesting));
- QCBORDecode_EnterBoundedMapOrArray(pMe, pSearch->uDataType, NULL);
+ QCBORDecode_Private_EnterBoundedMapOrArray(pMe, pSearch->uDataType, NULL);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_EnterMapFromMapN(QCBORDecodeContext *pMe, int64_t nLabel)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_EnterMapFromMapN(QCBORDecodeContext *pMe, int64_t nLabel)
{
QCBORItem OneItemSeach[2];
OneItemSeach[0].uLabelType = QCBOR_TYPE_INT64;
@@ -3593,14 +3646,15 @@
OneItemSeach[1].uLabelType = QCBOR_TYPE_NONE;
/* The map to enter was found, now finish off entering it. */
- SearchAndEnter(pMe, OneItemSeach);
+ QCBORDecode_Private_SearchAndEnter(pMe, OneItemSeach);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_EnterMapFromMapSZ(QCBORDecodeContext *pMe, const char *szLabel)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_EnterMapFromMapSZ(QCBORDecodeContext *pMe, const char *szLabel)
{
QCBORItem OneItemSeach[2];
OneItemSeach[0].uLabelType = QCBOR_TYPE_TEXT_STRING;
@@ -3608,13 +3662,14 @@
OneItemSeach[0].uDataType = QCBOR_TYPE_MAP;
OneItemSeach[1].uLabelType = QCBOR_TYPE_NONE;
- SearchAndEnter(pMe, OneItemSeach);
+ QCBORDecode_Private_SearchAndEnter(pMe, OneItemSeach);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_EnterArrayFromMapN(QCBORDecodeContext *pMe, int64_t nLabel)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_EnterArrayFromMapN(QCBORDecodeContext *pMe, int64_t nLabel)
{
QCBORItem OneItemSeach[2];
OneItemSeach[0].uLabelType = QCBOR_TYPE_INT64;
@@ -3622,13 +3677,14 @@
OneItemSeach[0].uDataType = QCBOR_TYPE_ARRAY;
OneItemSeach[1].uLabelType = QCBOR_TYPE_NONE;
- SearchAndEnter(pMe, OneItemSeach);
+ QCBORDecode_Private_SearchAndEnter(pMe, OneItemSeach);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_EnterArrayFromMapSZ(QCBORDecodeContext *pMe, const char *szLabel)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_EnterArrayFromMapSZ(QCBORDecodeContext *pMe, const char *szLabel)
{
QCBORItem OneItemSeach[2];
OneItemSeach[0].uLabelType = QCBOR_TYPE_TEXT_STRING;
@@ -3636,12 +3692,15 @@
OneItemSeach[0].uDataType = QCBOR_TYPE_ARRAY;
OneItemSeach[1].uLabelType = QCBOR_TYPE_NONE;
- SearchAndEnter(pMe, OneItemSeach);
+ QCBORDecode_Private_SearchAndEnter(pMe, OneItemSeach);
}
// Semi-private function
-void QCBORDecode_EnterBoundedMapOrArray(QCBORDecodeContext *pMe, uint8_t uType, QCBORItem *pItem)
+void
+QCBORDecode_Private_EnterBoundedMapOrArray(QCBORDecodeContext *pMe,
+ const uint8_t uType,
+ QCBORItem *pItem)
{
QCBORError uErr;
@@ -3662,7 +3721,7 @@
goto Done;
}
- CopyTags(pMe, &Item);
+ QCBORDecode_Private_CopyTags(pMe, &Item);
const bool bIsEmpty = (Item.uNextNestLevel <= Item.uNestingLevel);
@@ -3703,7 +3762,8 @@
mode or the top level if there isn't one.
*/
static QCBORError
-ExitBoundedLevel(QCBORDecodeContext *pMe, uint32_t uEndOffset)
+QCBORDecode_Private_ExitBoundedLevel(QCBORDecodeContext *pMe,
+ const uint32_t uEndOffset)
{
QCBORError uErr;
@@ -3728,7 +3788,7 @@
reached. It may do nothing, or ascend all the way to the top
level.
*/
- uErr = QCBORDecode_NestLevelAscender(pMe, false);
+ uErr = QCBORDecode_Private_NestLevelAscender(pMe, false);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
@@ -3748,7 +3808,9 @@
// Semi-private function
-void QCBORDecode_ExitBoundedMapOrArray(QCBORDecodeContext *pMe, uint8_t uType)
+void
+QCBORDecode_Private_ExitBoundedMapOrArray(QCBORDecodeContext *pMe,
+ const uint8_t uType)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
/* Already in error state; do nothing. */
@@ -3770,13 +3832,13 @@
if(pMe->uMapEndOffsetCache == QCBOR_MAP_OFFSET_CACHE_INVALID) {
QCBORItem Dummy;
Dummy.uLabelType = QCBOR_TYPE_NONE;
- uErr = MapSearch(pMe, &Dummy, NULL, NULL, NULL);
+ uErr = QCBORDecode_Private_MapSearch(pMe, &Dummy, NULL, NULL, NULL);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
}
- uErr = ExitBoundedLevel(pMe, pMe->uMapEndOffsetCache);
+ uErr = QCBORDecode_Private_ExitBoundedLevel(pMe, pMe->uMapEndOffsetCache);
Done:
pMe->uLastError = (uint8_t)uErr;
@@ -3785,10 +3847,10 @@
static QCBORError
-InternalEnterBstrWrapped(QCBORDecodeContext *pMe,
- const QCBORItem *pItem,
- const uint8_t uTagRequirement,
- UsefulBufC *pBstr)
+QCBORDecode_Private_EnterBstrWrapped(QCBORDecodeContext *pMe,
+ const QCBORItem *pItem,
+ const uint8_t uTagRequirement,
+ UsefulBufC *pBstr)
{
if(pBstr) {
*pBstr = NULLUsefulBufC;
@@ -3801,14 +3863,14 @@
QCBORError uError;
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QBCOR_TYPE_WRAPPED_CBOR, QBCOR_TYPE_WRAPPED_CBOR_SEQUENCE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- uError = CheckTagRequirement(TagSpec, pItem);
+ uError = QCBOR_Private_CheckTagRequirement(TagSpec, pItem);
if(uError != QCBOR_SUCCESS) {
goto Done;
}
@@ -3865,11 +3927,12 @@
/*
- Public function, see header qcbor/qcbor_decode.h file
+ * Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_EnterBstrWrapped(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC *pBstr)
+void
+QCBORDecode_EnterBstrWrapped(QCBORDecodeContext *pMe,
+ const uint8_t uTagRequirement,
+ UsefulBufC *pBstr)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
// Already in error state; do nothing.
@@ -3883,53 +3946,56 @@
return;
}
- pMe->uLastError = (uint8_t)InternalEnterBstrWrapped(pMe,
- &Item,
- uTagRequirement,
- pBstr);
+ pMe->uLastError = (uint8_t)QCBORDecode_Private_EnterBstrWrapped(pMe,
+ &Item,
+ uTagRequirement,
+ pBstr);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
+ * Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_EnterBstrWrappedFromMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC *pBstr)
+void
+QCBORDecode_EnterBstrWrappedFromMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ UsefulBufC *pBstr)
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
- pMe->uLastError = (uint8_t)InternalEnterBstrWrapped(pMe,
- &Item,
- uTagRequirement,
- pBstr);
+ pMe->uLastError = (uint8_t)QCBORDecode_Private_EnterBstrWrapped(pMe,
+ &Item,
+ uTagRequirement,
+ pBstr);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
+ * Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_EnterBstrWrappedFromMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC *pBstr)
+void
+QCBORDecode_EnterBstrWrappedFromMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint8_t uTagRequirement,
+ UsefulBufC *pBstr)
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
- pMe->uLastError = (uint8_t)InternalEnterBstrWrapped(pMe,
- &Item,
- uTagRequirement,
- pBstr);
+ pMe->uLastError = (uint8_t)QCBORDecode_Private_EnterBstrWrapped(pMe,
+ &Item,
+ uTagRequirement,
+ pBstr);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
+ * Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_ExitBstrWrapped(QCBORDecodeContext *pMe)
+void
+QCBORDecode_ExitBstrWrapped(QCBORDecodeContext *pMe)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
// Already in error state; do nothing.
@@ -3951,15 +4017,17 @@
DecodeNesting_GetPreviousBoundedEnd(&(pMe->nesting)));
- QCBORError uErr = ExitBoundedLevel(pMe, uEndOfBstr);
+ QCBORError uErr = QCBORDecode_Private_ExitBoundedLevel(pMe, uEndOfBstr);
pMe->uLastError = (uint8_t)uErr;
}
-static inline void
-ProcessBool(QCBORDecodeContext *pMe, const QCBORItem *pItem, bool *pBool)
+static void
+QCBORDecode_Private_ProcessBool(QCBORDecodeContext *pMe,
+ const QCBORItem *pItem,
+ bool *pBool)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
/* Already in error state, do nothing */
@@ -3979,14 +4047,15 @@
pMe->uLastError = QCBOR_ERR_UNEXPECTED_TYPE;
break;
}
- CopyTags(pMe, pItem);
+ QCBORDecode_Private_CopyTags(pMe, pItem);
}
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_GetBool(QCBORDecodeContext *pMe, bool *pValue)
+void
+QCBORDecode_GetBool(QCBORDecodeContext *pMe, bool *pValue)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
/* Already in error state, do nothing */
@@ -3997,40 +4066,47 @@
pMe->uLastError = (uint8_t)QCBORDecode_GetNext(pMe, &Item);
- ProcessBool(pMe, &Item, pValue);
+ QCBORDecode_Private_ProcessBool(pMe, &Item, pValue);
}
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_GetBoolInMapN(QCBORDecodeContext *pMe, int64_t nLabel, bool *pValue)
+void
+QCBORDecode_GetBoolInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ bool *pValue)
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
- ProcessBool(pMe, &Item, pValue);
+ QCBORDecode_Private_ProcessBool(pMe, &Item, pValue);
}
/*
* Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_GetBoolInMapSZ(QCBORDecodeContext *pMe, const char *szLabel, bool *pValue)
+void
+QCBORDecode_GetBoolInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ bool *pValue)
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
- ProcessBool(pMe, &Item, pValue);
+ QCBORDecode_Private_ProcessBool(pMe, &Item, pValue);
}
-static void ProcessEpochDate(QCBORDecodeContext *pMe,
- QCBORItem *pItem,
- const uint8_t uTagRequirement,
- int64_t *pnTime)
+static void
+QCBORDecode_Private_ProcessEpochDate(QCBORDecodeContext *pMe,
+ QCBORItem *pItem,
+ const uint8_t uTagRequirement,
+ int64_t *pnTime)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
// Already in error state, do nothing
@@ -4039,20 +4115,20 @@
QCBORError uErr;
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DATE_EPOCH, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_INT64, QCBOR_TYPE_DOUBLE, QCBOR_TYPE_FLOAT, QCBOR_TYPE_UINT64}
};
- uErr = CheckTagRequirement(TagSpec, pItem);
+ uErr = QCBOR_Private_CheckTagRequirement(TagSpec, pItem);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
if(pItem->uDataType != QCBOR_TYPE_DATE_EPOCH) {
- uErr = DecodeDateEpoch(pItem);
+ uErr = QCBOR_Private_DecodeDateEpoch(pItem);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
@@ -4060,7 +4136,7 @@
// Save the tags in the last item's tags in the decode context
// for QCBORDecode_GetNthTagOfLast()
- CopyTags(pMe, pItem);
+ QCBORDecode_Private_CopyTags(pMe, pItem);
*pnTime = pItem->val.epochDate.nSeconds;
@@ -4069,9 +4145,10 @@
}
-void QCBORDecode_GetEpochDate(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- int64_t *pnTime)
+void
+QCBORDecode_GetEpochDate(QCBORDecodeContext *pMe,
+ uint8_t uTagRequirement,
+ int64_t *pnTime)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
// Already in error state, do nothing
@@ -4081,7 +4158,7 @@
QCBORItem Item;
pMe->uLastError = (uint8_t)QCBORDecode_GetNext(pMe, &Item);
- ProcessEpochDate(pMe, &Item, uTagRequirement, pnTime);
+ QCBORDecode_Private_ProcessEpochDate(pMe, &Item, uTagRequirement, pnTime);
}
@@ -4093,7 +4170,7 @@
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
- ProcessEpochDate(pMe, &Item, uTagRequirement, pnTime);
+ QCBORDecode_Private_ProcessEpochDate(pMe, &Item, uTagRequirement, pnTime);
}
@@ -4105,7 +4182,7 @@
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
- ProcessEpochDate(pMe, &Item, uTagRequirement, pnTime);
+ QCBORDecode_Private_ProcessEpochDate(pMe, &Item, uTagRequirement, pnTime);
}
@@ -4115,10 +4192,11 @@
* make sure the tag content is correct and copy forward any
* further other tag numbers.
*/
-static void ProcessEpochDays(QCBORDecodeContext *pMe,
- QCBORItem *pItem,
- uint8_t uTagRequirement,
- int64_t *pnDays)
+static void
+QCBORDecode_Private_ProcessEpochDays(QCBORDecodeContext *pMe,
+ QCBORItem *pItem,
+ uint8_t uTagRequirement,
+ int64_t *pnDays)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
/* Already in error state, do nothing */
@@ -4127,20 +4205,20 @@
QCBORError uErr;
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DAYS_EPOCH, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_INT64, QCBOR_TYPE_UINT64, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- uErr = CheckTagRequirement(TagSpec, pItem);
+ uErr = QCBOR_Private_CheckTagRequirement(TagSpec, pItem);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
if(pItem->uDataType != QCBOR_TYPE_DAYS_EPOCH) {
- uErr = DecodeDaysEpoch(pItem);
+ uErr = QCBOR_Private_DecodeDaysEpoch(pItem);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
@@ -4149,7 +4227,7 @@
/* Save the tags in the last item's tags in the decode context
* for QCBORDecode_GetNthTagOfLast()
*/
- CopyTags(pMe, pItem);
+ QCBORDecode_Private_CopyTags(pMe, pItem);
*pnDays = pItem->val.epochDays;
@@ -4161,9 +4239,10 @@
/*
* Public function, see header qcbor/qcbor_decode.h
*/
-void QCBORDecode_GetEpochDays(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- int64_t *pnDays)
+void
+QCBORDecode_GetEpochDays(QCBORDecodeContext *pMe,
+ uint8_t uTagRequirement,
+ int64_t *pnDays)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
/* Already in error state, do nothing */
@@ -4173,7 +4252,7 @@
QCBORItem Item;
pMe->uLastError = (uint8_t)QCBORDecode_GetNext(pMe, &Item);
- ProcessEpochDays(pMe, &Item, uTagRequirement, pnDays);
+ QCBORDecode_Private_ProcessEpochDays(pMe, &Item, uTagRequirement, pnDays);
}
@@ -4188,7 +4267,7 @@
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
- ProcessEpochDays(pMe, &Item, uTagRequirement, pnDays);
+ QCBORDecode_Private_ProcessEpochDays(pMe, &Item, uTagRequirement, pnDays);
}
@@ -4203,7 +4282,7 @@
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
- ProcessEpochDays(pMe, &Item, uTagRequirement, pnDays);
+ QCBORDecode_Private_ProcessEpochDays(pMe, &Item, uTagRequirement, pnDays);
}
@@ -4212,9 +4291,9 @@
* @brief Get a string that matches the type/tag specification.
*/
void
-QCBORDecode_GetTaggedStringInternal(QCBORDecodeContext *pMe,
- const TagSpecification TagSpec,
- UsefulBufC *pBstr)
+QCBORDecode_Private_GetTaggedString(QCBORDecodeContext *pMe,
+ const QCBOR_Private_TagSpec TagSpec,
+ UsefulBufC *pBstr)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
/* Already in error state, do nothing */
@@ -4230,7 +4309,7 @@
return;
}
- pMe->uLastError = (uint8_t)CheckTagRequirement(TagSpec, &Item);
+ pMe->uLastError = (uint8_t)QCBOR_Private_CheckTagRequirement(TagSpec, &Item);
if(pMe->uLastError == QCBOR_SUCCESS) {
*pBstr = Item.val.string;
@@ -4243,19 +4322,19 @@
static QCBORError
-ProcessBigNum(const uint8_t uTagRequirement,
- const QCBORItem *pItem,
- UsefulBufC *pValue,
- bool *pbIsNegative)
+QCBOR_Private_ProcessBigNum(const uint8_t uTagRequirement,
+ const QCBORItem *pItem,
+ UsefulBufC *pValue,
+ bool *pbIsNegative)
{
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_POSBIGNUM, QCBOR_TYPE_NEGBIGNUM, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- QCBORError uErr = CheckTagRequirement(TagSpec, pItem);
+ QCBORError uErr = QCBOR_Private_CheckTagRequirement(TagSpec, pItem);
if(uErr != QCBOR_SUCCESS) {
return uErr;
}
@@ -4275,10 +4354,11 @@
/*
Public function, see header qcbor/qcbor_decode.h
*/
-void QCBORDecode_GetBignum(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBufC *pValue,
- bool *pbIsNegative)
+void
+QCBORDecode_GetBignum(QCBORDecodeContext *pMe,
+ const uint8_t uTagRequirement,
+ UsefulBufC *pValue,
+ bool *pbIsNegative)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
// Already in error state, do nothing
@@ -4292,18 +4372,22 @@
return;
}
- pMe->uLastError = (uint8_t)ProcessBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ProcessBigNum(uTagRequirement,
+ &Item,
+ pValue,
+ pbIsNegative);
}
/*
Public function, see header qcbor/qcbor_decode.h
*/
-void QCBORDecode_GetBignumInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBufC *pValue,
- bool *pbIsNegative)
+void
+QCBORDecode_GetBignumInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ UsefulBufC *pValue,
+ bool *pbIsNegative)
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
@@ -4311,18 +4395,22 @@
return;
}
- pMe->uLastError = (uint8_t)ProcessBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ProcessBigNum(uTagRequirement,
+ &Item,
+ pValue,
+ pbIsNegative);
}
/*
- Public function, see header qcbor/qcbor_decode.h
-*/
-void QCBORDecode_GetBignumInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBufC *pValue,
- bool *pbIsNegative)
+ * Public function, see header qcbor/qcbor_decode.h
+ */
+void
+QCBORDecode_GetBignumInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint8_t uTagRequirement,
+ UsefulBufC *pValue,
+ bool *pbIsNegative)
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
@@ -4330,7 +4418,10 @@
return;
}
- pMe->uLastError = (uint8_t)ProcessBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ProcessBigNum(uTagRequirement,
+ &Item,
+ pValue,
+ pbIsNegative);
}
@@ -4338,18 +4429,18 @@
// Semi private
QCBORError
-QCBORDecode_GetMIMEInternal(const uint8_t uTagRequirement,
+QCBORDecode_Private_GetMIME(const uint8_t uTagRequirement,
const QCBORItem *pItem,
UsefulBufC *pMessage,
bool *pbIsTag257)
{
- const TagSpecification TagSpecText =
+ const QCBOR_Private_TagSpec TagSpecText =
{
uTagRequirement,
{QCBOR_TYPE_MIME, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
{QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- const TagSpecification TagSpecBinary =
+ const QCBOR_Private_TagSpec TagSpecBinary =
{
uTagRequirement,
{QCBOR_TYPE_BINARY_MIME, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
@@ -4358,13 +4449,13 @@
QCBORError uReturn;
- if(CheckTagRequirement(TagSpecText, pItem) == QCBOR_SUCCESS) {
+ if(QCBOR_Private_CheckTagRequirement(TagSpecText, pItem) == QCBOR_SUCCESS) {
*pMessage = pItem->val.string;
if(pbIsTag257 != NULL) {
*pbIsTag257 = false;
}
uReturn = QCBOR_SUCCESS;
- } else if(CheckTagRequirement(TagSpecBinary, pItem) == QCBOR_SUCCESS) {
+ } else if(QCBOR_Private_CheckTagRequirement(TagSpecBinary, pItem) == QCBOR_SUCCESS) {
*pMessage = pItem->val.string;
if(pbIsTag257 != NULL) {
*pbIsTag257 = true;
@@ -4404,7 +4495,9 @@
* be returned.
*/
static QCBORError
-Exponentitate10(uint64_t uMantissa, int64_t nExponent, uint64_t *puResult)
+QCBOR_Private_Exponentitate10(const uint64_t uMantissa,
+ int64_t nExponent,
+ uint64_t *puResult)
{
uint64_t uResult = uMantissa;
@@ -4450,7 +4543,9 @@
* be returned.
*/
static QCBORError
-Exponentitate2(uint64_t uMantissa, int64_t nExponent, uint64_t *puResult)
+QCBOR_Private_Exponentitate2(const uint64_t uMantissa,
+ int64_t nExponent,
+ uint64_t *puResult)
{
uint64_t uResult;
@@ -4497,10 +4592,10 @@
* either for base 2 or base 10 (and could be other if needed).
*/
static QCBORError
-ExponentiateNN(int64_t nMantissa,
- int64_t nExponent,
- int64_t *pnResult,
- fExponentiator pfExp)
+QCBOR_Private_ExponentiateNN(const int64_t nMantissa,
+ const int64_t nExponent,
+ int64_t *pnResult,
+ fExponentiator pfExp)
{
uint64_t uResult;
uint64_t uMantissa;
@@ -4584,10 +4679,10 @@
* is negative because the output is unsigned.
*/
static QCBORError
-ExponentitateNU(int64_t nMantissa,
- int64_t nExponent,
- uint64_t *puResult,
- fExponentiator pfExp)
+QCBOR_Private_ExponentitateNU(const int64_t nMantissa,
+ const int64_t nExponent,
+ uint64_t *puResult,
+ fExponentiator pfExp)
{
if(nMantissa < 0) {
return QCBOR_ERR_NUMBER_SIGN_CONVERSION;
@@ -4616,10 +4711,10 @@
* nothing (and is likely inlined).
*/
static QCBORError
-ExponentitateUU(uint64_t uMantissa,
- int64_t nExponent,
- uint64_t *puResult,
- fExponentiator pfExp)
+QCBOR_Private_ExponentitateUU(const uint64_t uMantissa,
+ const int64_t nExponent,
+ uint64_t *puResult,
+ fExponentiator pfExp)
{
return (*pfExp)(uMantissa, nExponent, puResult);
}
@@ -4642,7 +4737,9 @@
* larger range than uint64_t.
*/
static QCBORError
-ConvertBigNumToUnsigned(const UsefulBufC BigNum, const uint64_t uMax, uint64_t *pResult)
+QCBOR_Private_ConvertBigNumToUnsigned(const UsefulBufC BigNum,
+ const uint64_t uMax,
+ uint64_t *pResult)
{
uint64_t uResult;
@@ -4673,9 +4770,10 @@
* larger range than uint64_t.
*/
static QCBORError
-ConvertPositiveBigNumToUnsigned(const UsefulBufC BigNum, uint64_t *pResult)
+QCBOR_Private_ConvertPositiveBigNumToUnsigned(const UsefulBufC BigNum,
+ uint64_t *pResult)
{
- return ConvertBigNumToUnsigned(BigNum, UINT64_MAX, pResult);
+ return QCBOR_Private_ConvertBigNumToUnsigned(BigNum, UINT64_MAX, pResult);
}
@@ -4691,14 +4789,17 @@
* larger range than int64_t.
*/
static QCBORError
-ConvertPositiveBigNumToSigned(const UsefulBufC BigNum, int64_t *pResult)
+QCBOR_Private_ConvertPositiveBigNumToSigned(const UsefulBufC BigNum,
+ int64_t *pResult)
{
uint64_t uResult;
- QCBORError uError = ConvertBigNumToUnsigned(BigNum, INT64_MAX, &uResult);
+ QCBORError uError = QCBOR_Private_ConvertBigNumToUnsigned(BigNum,
+ INT64_MAX,
+ &uResult);
if(uError) {
return uError;
}
- /* Cast is safe because ConvertBigNumToUnsigned is told to limit to INT64_MAX */
+ /* Cast is safe because ConvertBigNumToUnsigned limits to INT64_MAX */
*pResult = (int64_t)uResult;
return QCBOR_SUCCESS;
}
@@ -4716,7 +4817,8 @@
* larger range than int64_t.
*/
static QCBORError
-ConvertNegativeBigNumToSigned(const UsefulBufC BigNum, int64_t *pnResult)
+QCBOR_Private_ConvertNegativeBigNumToSigned(const UsefulBufC BigNum,
+ int64_t *pnResult)
{
uint64_t uResult;
/* The negative integer furthest from zero for a C int64_t is
@@ -4731,7 +4833,9 @@
* -n - 1 <= -INT64_MAX - 1
* n <= INT64_MAX.
*/
- QCBORError uError = ConvertBigNumToUnsigned(BigNum, INT64_MAX, &uResult);
+ QCBORError uError = QCBOR_Private_ConvertBigNumToUnsigned(BigNum,
+ INT64_MAX,
+ &uResult);
if(uError != QCBOR_SUCCESS) {
return uError;
}
@@ -4763,7 +4867,9 @@
or too small.
*/
static QCBORError
-ConvertInt64(const QCBORItem *pItem, uint32_t uConvertTypes, int64_t *pnValue)
+QCBOR_Private_ConvertInt64(const QCBORItem *pItem,
+ const uint32_t uConvertTypes,
+ int64_t *pnValue)
{
switch(pItem->uDataType) {
case QCBOR_TYPE_FLOAT:
@@ -4822,10 +4928,11 @@
}
-void QCBORDecode_GetInt64ConvertInternal(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
- int64_t *pnValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetInt64Convert(QCBORDecodeContext *pMe,
+ uint32_t uConvertTypes,
+ int64_t *pnValue,
+ QCBORItem *pItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -4842,37 +4949,45 @@
*pItem = Item;
}
- pMe->uLastError = (uint8_t)ConvertInt64(&Item, uConvertTypes, pnValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertInt64(&Item,
+ uConvertTypes,
+ pnValue);
}
-void QCBORDecode_GetInt64ConvertInternalInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
- int64_t *pnValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetInt64ConvertInMapN(QCBORDecodeContext *pMe,
+ int64_t nLabel,
+ uint32_t uConvertTypes,
+ int64_t *pnValue,
+ QCBORItem *pItem)
{
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, pItem);
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
}
- pMe->uLastError = (uint8_t)ConvertInt64(pItem, uConvertTypes, pnValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertInt64(pItem,
+ uConvertTypes,
+ pnValue);
}
-void QCBORDecode_GetInt64ConvertInternalInMapSZ(QCBORDecodeContext *pMe,
- const char * szLabel,
- uint32_t uConvertTypes,
- int64_t *pnValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetInt64ConvertInMapSZ(QCBORDecodeContext *pMe,
+ const char * szLabel,
+ uint32_t uConvertTypes,
+ int64_t *pnValue,
+ QCBORItem *pItem)
{
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, pItem);
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
}
- pMe->uLastError = (uint8_t)ConvertInt64(pItem, uConvertTypes, pnValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertInt64(pItem,
+ uConvertTypes,
+ pnValue);
}
@@ -4890,13 +5005,15 @@
or too small.
*/
static QCBORError
-Int64ConvertAll(const QCBORItem *pItem, uint32_t uConvertTypes, int64_t *pnValue)
+QCBOR_Private_Int64ConvertAll(const QCBORItem *pItem,
+ const uint32_t uConvertTypes,
+ int64_t *pnValue)
{
switch(pItem->uDataType) {
case QCBOR_TYPE_POSBIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIG_NUM) {
- return ConvertPositiveBigNumToSigned(pItem->val.bigNum, pnValue);
+ return QCBOR_Private_ConvertPositiveBigNumToSigned(pItem->val.bigNum, pnValue);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -4904,7 +5021,7 @@
case QCBOR_TYPE_NEGBIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIG_NUM) {
- return ConvertNegativeBigNumToSigned(pItem->val.bigNum, pnValue);
+ return QCBOR_Private_ConvertNegativeBigNumToSigned(pItem->val.bigNum, pnValue);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -4913,10 +5030,10 @@
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
case QCBOR_TYPE_DECIMAL_FRACTION:
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
- return ExponentiateNN(pItem->val.expAndMantissa.Mantissa.nInt,
+ return QCBOR_Private_ExponentiateNN(pItem->val.expAndMantissa.Mantissa.nInt,
pItem->val.expAndMantissa.nExponent,
pnValue,
- &Exponentitate10);
+ &QCBOR_Private_Exponentitate10);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -4924,10 +5041,10 @@
case QCBOR_TYPE_BIGFLOAT:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIGFLOAT) {
- return ExponentiateNN(pItem->val.expAndMantissa.Mantissa.nInt,
+ return QCBOR_Private_ExponentiateNN(pItem->val.expAndMantissa.Mantissa.nInt,
pItem->val.expAndMantissa.nExponent,
pnValue,
- Exponentitate2);
+ QCBOR_Private_Exponentitate2);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -4937,14 +5054,14 @@
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
int64_t nMantissa;
QCBORError uErr;
- uErr = ConvertPositiveBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, &nMantissa);
+ uErr = QCBOR_Private_ConvertPositiveBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, &nMantissa);
if(uErr) {
return uErr;
}
- return ExponentiateNN(nMantissa,
+ return QCBOR_Private_ExponentiateNN(nMantissa,
pItem->val.expAndMantissa.nExponent,
pnValue,
- Exponentitate10);
+ QCBOR_Private_Exponentitate10);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -4954,14 +5071,14 @@
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
int64_t nMantissa;
QCBORError uErr;
- uErr = ConvertNegativeBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, &nMantissa);
+ uErr = QCBOR_Private_ConvertNegativeBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, &nMantissa);
if(uErr) {
return uErr;
}
- return ExponentiateNN(nMantissa,
+ return QCBOR_Private_ExponentiateNN(nMantissa,
pItem->val.expAndMantissa.nExponent,
pnValue,
- Exponentitate10);
+ QCBOR_Private_Exponentitate10);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -4971,14 +5088,14 @@
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
int64_t nMantissa;
QCBORError uErr;
- uErr = ConvertPositiveBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, &nMantissa);
+ uErr = QCBOR_Private_ConvertPositiveBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, &nMantissa);
if(uErr) {
return uErr;
}
- return ExponentiateNN(nMantissa,
+ return QCBOR_Private_ExponentiateNN(nMantissa,
pItem->val.expAndMantissa.nExponent,
pnValue,
- Exponentitate2);
+ QCBOR_Private_Exponentitate2);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -4988,14 +5105,14 @@
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
int64_t nMantissa;
QCBORError uErr;
- uErr = ConvertNegativeBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, &nMantissa);
+ uErr = QCBOR_Private_ConvertNegativeBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, &nMantissa);
if(uErr) {
return uErr;
}
- return ExponentiateNN(nMantissa,
+ return QCBOR_Private_ExponentiateNN(nMantissa,
pItem->val.expAndMantissa.nExponent,
pnValue,
- Exponentitate2);
+ QCBOR_Private_Exponentitate2);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -5009,13 +5126,16 @@
/*
- Public function, see header qcbor/qcbor_decode.h file
+ * Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_GetInt64ConvertAll(QCBORDecodeContext *pMe, uint32_t uConvertTypes, int64_t *pnValue)
+void
+QCBORDecode_GetInt64ConvertAll(QCBORDecodeContext *pMe,
+ const uint32_t uConvertTypes,
+ int64_t *pnValue)
{
QCBORItem Item;
- QCBORDecode_GetInt64ConvertInternal(pMe, uConvertTypes, pnValue, &Item);
+ QCBORDecode_Private_GetInt64Convert(pMe, uConvertTypes, pnValue, &Item);
if(pMe->uLastError == QCBOR_SUCCESS) {
// The above conversion succeeded
@@ -5027,21 +5147,24 @@
return;
}
- pMe->uLastError = (uint8_t)Int64ConvertAll(&Item, uConvertTypes, pnValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_Int64ConvertAll(&Item,
+ uConvertTypes,
+ pnValue);
}
/*
-Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetInt64ConvertAllInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
- int64_t *pnValue)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetInt64ConvertAllInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint32_t uConvertTypes,
+ int64_t *pnValue)
{
QCBORItem Item;
- QCBORDecode_GetInt64ConvertInternalInMapN(pMe,
+ QCBORDecode_Private_GetInt64ConvertInMapN(pMe,
nLabel,
uConvertTypes,
pnValue,
@@ -5057,20 +5180,23 @@
return;
}
- pMe->uLastError = (uint8_t)Int64ConvertAll(&Item, uConvertTypes, pnValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_Int64ConvertAll(&Item,
+ uConvertTypes,
+ pnValue);
}
/*
-Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetInt64ConvertAllInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint32_t uConvertTypes,
- int64_t *pnValue)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetInt64ConvertAllInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint32_t uConvertTypes,
+ int64_t *pnValue)
{
QCBORItem Item;
- QCBORDecode_GetInt64ConvertInternalInMapSZ(pMe,
+ QCBORDecode_Private_GetInt64ConvertInMapSZ(pMe,
szLabel,
uConvertTypes,
pnValue,
@@ -5086,11 +5212,16 @@
return;
}
- pMe->uLastError = (uint8_t)Int64ConvertAll(&Item, uConvertTypes, pnValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_Int64ConvertAll(&Item,
+ uConvertTypes,
+ pnValue);
}
-static QCBORError ConvertUInt64(const QCBORItem *pItem, uint32_t uConvertTypes, uint64_t *puValue)
+static QCBORError
+QCBOR_Private_ConvertUInt64(const QCBORItem *pItem,
+ const uint32_t uConvertTypes,
+ uint64_t *puValue)
{
switch(pItem->uDataType) {
case QCBOR_TYPE_DOUBLE:
@@ -5174,10 +5305,11 @@
}
-void QCBORDecode_GetUInt64ConvertInternal(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
- uint64_t *puValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetUInt64Convert(QCBORDecodeContext *pMe,
+ const uint32_t uConvertTypes,
+ uint64_t *puValue,
+ QCBORItem *pItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -5195,30 +5327,36 @@
*pItem = Item;
}
- pMe->uLastError = (uint8_t)ConvertUInt64(&Item, uConvertTypes, puValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertUInt64(&Item,
+ uConvertTypes,
+ puValue);
}
-void QCBORDecode_GetUInt64ConvertInternalInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
- uint64_t *puValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetUInt64ConvertInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint32_t uConvertTypes,
+ uint64_t *puValue,
+ QCBORItem *pItem)
{
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, pItem);
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
}
- pMe->uLastError = (uint8_t)ConvertUInt64(pItem, uConvertTypes, puValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertUInt64(pItem,
+ uConvertTypes,
+ puValue);
}
-void QCBORDecode_GetUInt64ConvertInternalInMapSZ(QCBORDecodeContext *pMe,
- const char * szLabel,
- uint32_t uConvertTypes,
- uint64_t *puValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetUInt64ConvertInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint32_t uConvertTypes,
+ uint64_t *puValue,
+ QCBORItem *pItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -5229,19 +5367,23 @@
return;
}
- pMe->uLastError = (uint8_t)ConvertUInt64(pItem, uConvertTypes, puValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertUInt64(pItem,
+ uConvertTypes,
+ puValue);
}
static QCBORError
-UInt64ConvertAll(const QCBORItem *pItem, uint32_t uConvertTypes, uint64_t *puValue)
+QCBOR_Private_UInt64ConvertAll(const QCBORItem *pItem,
+ const uint32_t uConvertTypes,
+ uint64_t *puValue)
{
switch(pItem->uDataType) { /* -Wmaybe-uninitialized falsly warns here */
case QCBOR_TYPE_POSBIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIG_NUM) {
- return ConvertPositiveBigNumToUnsigned(pItem->val.bigNum, puValue);
+ return QCBOR_Private_ConvertPositiveBigNumToUnsigned(pItem->val.bigNum, puValue);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -5259,10 +5401,10 @@
case QCBOR_TYPE_DECIMAL_FRACTION:
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
- return ExponentitateNU(pItem->val.expAndMantissa.Mantissa.nInt,
+ return QCBOR_Private_ExponentitateNU(pItem->val.expAndMantissa.Mantissa.nInt,
pItem->val.expAndMantissa.nExponent,
puValue,
- Exponentitate10);
+ QCBOR_Private_Exponentitate10);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -5270,10 +5412,10 @@
case QCBOR_TYPE_BIGFLOAT:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIGFLOAT) {
- return ExponentitateNU(pItem->val.expAndMantissa.Mantissa.nInt,
+ return QCBOR_Private_ExponentitateNU(pItem->val.expAndMantissa.Mantissa.nInt,
pItem->val.expAndMantissa.nExponent,
puValue,
- Exponentitate2);
+ QCBOR_Private_Exponentitate2);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -5283,14 +5425,14 @@
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
uint64_t uMantissa;
QCBORError uErr;
- uErr = ConvertPositiveBigNumToUnsigned(pItem->val.expAndMantissa.Mantissa.bigNum, &uMantissa);
+ uErr = QCBOR_Private_ConvertPositiveBigNumToUnsigned(pItem->val.expAndMantissa.Mantissa.bigNum, &uMantissa);
if(uErr != QCBOR_SUCCESS) {
return uErr;
}
- return ExponentitateUU(uMantissa,
- pItem->val.expAndMantissa.nExponent,
- puValue,
- Exponentitate10);
+ return QCBOR_Private_ExponentitateUU(uMantissa,
+ pItem->val.expAndMantissa.nExponent,
+ puValue,
+ QCBOR_Private_Exponentitate10);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -5308,14 +5450,15 @@
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
uint64_t uMantissa;
QCBORError uErr;
- uErr = ConvertPositiveBigNumToUnsigned(pItem->val.expAndMantissa.Mantissa.bigNum, &uMantissa);
+ uErr = QCBOR_Private_ConvertPositiveBigNumToUnsigned(pItem->val.expAndMantissa.Mantissa.bigNum,
+ &uMantissa);
if(uErr != QCBOR_SUCCESS) {
return uErr;
}
- return ExponentitateUU(uMantissa,
- pItem->val.expAndMantissa.nExponent,
- puValue,
- Exponentitate2);
+ return QCBOR_Private_ExponentitateUU(uMantissa,
+ pItem->val.expAndMantissa.nExponent,
+ puValue,
+ QCBOR_Private_Exponentitate2);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -5336,13 +5479,16 @@
/*
- Public function, see header qcbor/qcbor_decode.h file
+ * Public function, see header qcbor/qcbor_decode.h file
*/
-void QCBORDecode_GetUInt64ConvertAll(QCBORDecodeContext *pMe, uint32_t uConvertTypes, uint64_t *puValue)
+void
+QCBORDecode_GetUInt64ConvertAll(QCBORDecodeContext *pMe,
+ const uint32_t uConvertTypes,
+ uint64_t *puValue)
{
QCBORItem Item;
- QCBORDecode_GetUInt64ConvertInternal(pMe, uConvertTypes, puValue, &Item);
+ QCBORDecode_Private_GetUInt64Convert(pMe, uConvertTypes, puValue, &Item);
if(pMe->uLastError == QCBOR_SUCCESS) {
// The above conversion succeeded
@@ -5354,21 +5500,24 @@
return;
}
- pMe->uLastError = (uint8_t)UInt64ConvertAll(&Item, uConvertTypes, puValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_UInt64ConvertAll(&Item,
+ uConvertTypes,
+ puValue);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetUInt64ConvertAllInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
- uint64_t *puValue)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetUInt64ConvertAllInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint32_t uConvertTypes,
+ uint64_t *puValue)
{
QCBORItem Item;
- QCBORDecode_GetUInt64ConvertInternalInMapN(pMe,
+ QCBORDecode_Private_GetUInt64ConvertInMapN(pMe,
nLabel,
uConvertTypes,
puValue,
@@ -5384,20 +5533,23 @@
return;
}
- pMe->uLastError = (uint8_t)UInt64ConvertAll(&Item, uConvertTypes, puValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_UInt64ConvertAll(&Item,
+ uConvertTypes,
+ puValue);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetUInt64ConvertAllInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint32_t uConvertTypes,
- uint64_t *puValue)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetUInt64ConvertAllInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint32_t uConvertTypes,
+ uint64_t *puValue)
{
QCBORItem Item;
- QCBORDecode_GetUInt64ConvertInternalInMapSZ(pMe,
+ QCBORDecode_Private_GetUInt64ConvertInMapSZ(pMe,
szLabel,
uConvertTypes,
puValue,
@@ -5413,16 +5565,19 @@
return;
}
- pMe->uLastError = (uint8_t)UInt64ConvertAll(&Item, uConvertTypes, puValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_UInt64ConvertAll(&Item,
+ uConvertTypes,
+ puValue);
}
#ifndef USEFULBUF_DISABLE_ALL_FLOAT
-static QCBORError ConvertDouble(const QCBORItem *pItem,
- uint32_t uConvertTypes,
- double *pdValue)
+static QCBORError
+QCBOR_Private_ConvertDouble(const QCBORItem *pItem,
+ const uint32_t uConvertTypes,
+ double *pdValue)
{
switch(pItem->uDataType) {
case QCBOR_TYPE_FLOAT:
@@ -5487,10 +5642,11 @@
}
-void QCBORDecode_GetDoubleConvertInternal(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
- double *pdValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetDoubleConvert(QCBORDecodeContext *pMe,
+ const uint32_t uConvertTypes,
+ double *pdValue,
+ QCBORItem *pItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -5508,30 +5664,36 @@
*pItem = Item;
}
- pMe->uLastError = (uint8_t)ConvertDouble(&Item, uConvertTypes, pdValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertDouble(&Item,
+ uConvertTypes,
+ pdValue);
}
-void QCBORDecode_GetDoubleConvertInternalInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
- double *pdValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetDoubleConvertInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint32_t uConvertTypes,
+ double *pdValue,
+ QCBORItem *pItem)
{
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, pItem);
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
}
- pMe->uLastError = (uint8_t)ConvertDouble(pItem, uConvertTypes, pdValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertDouble(pItem,
+ uConvertTypes,
+ pdValue);
}
-void QCBORDecode_GetDoubleConvertInternalInMapSZ(QCBORDecodeContext *pMe,
- const char * szLabel,
- uint32_t uConvertTypes,
- double *pdValue,
- QCBORItem *pItem)
+void
+QCBORDecode_Private_GetDoubleConvertInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint32_t uConvertTypes,
+ double *pdValue,
+ QCBORItem *pItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -5542,12 +5704,15 @@
return;
}
- pMe->uLastError = (uint8_t)ConvertDouble(pItem, uConvertTypes, pdValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_ConvertDouble(pItem,
+ uConvertTypes,
+ pdValue);
}
#ifndef QCBOR_DISABLE_FLOAT_HW_USE
-static double ConvertBigNumToDouble(const UsefulBufC BigNum)
+static double
+QCBOR_Private_ConvertBigNumToDouble(const UsefulBufC BigNum)
{
double dResult;
@@ -5566,7 +5731,9 @@
static QCBORError
-DoubleConvertAll(const QCBORItem *pItem, uint32_t uConvertTypes, double *pdValue)
+QCBOR_Private_DoubleConvertAll(const QCBORItem *pItem,
+ const uint32_t uConvertTypes,
+ double *pdValue)
{
#ifndef QCBOR_DISABLE_FLOAT_HW_USE
/*
@@ -5599,7 +5766,7 @@
case QCBOR_TYPE_POSBIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIG_NUM) {
- *pdValue = ConvertBigNumToDouble(pItem->val.bigNum);
+ *pdValue = QCBOR_Private_ConvertBigNumToDouble(pItem->val.bigNum);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -5607,7 +5774,7 @@
case QCBOR_TYPE_NEGBIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIG_NUM) {
- *pdValue = -1-ConvertBigNumToDouble(pItem->val.bigNum);
+ *pdValue = -1-QCBOR_Private_ConvertBigNumToDouble(pItem->val.bigNum);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -5616,7 +5783,7 @@
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
case QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
- double dMantissa = ConvertBigNumToDouble(pItem->val.expAndMantissa.Mantissa.bigNum);
+ double dMantissa = QCBOR_Private_ConvertBigNumToDouble(pItem->val.expAndMantissa.Mantissa.bigNum);
*pdValue = dMantissa * pow(10, (double)pItem->val.expAndMantissa.nExponent);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
@@ -5625,7 +5792,7 @@
case QCBOR_TYPE_DECIMAL_FRACTION_NEG_BIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_DECIMAL_FRACTION) {
- double dMantissa = -ConvertBigNumToDouble(pItem->val.expAndMantissa.Mantissa.bigNum);
+ double dMantissa = -QCBOR_Private_ConvertBigNumToDouble(pItem->val.expAndMantissa.Mantissa.bigNum);
*pdValue = dMantissa * pow(10, (double)pItem->val.expAndMantissa.nExponent);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
@@ -5634,7 +5801,7 @@
case QCBOR_TYPE_BIGFLOAT_POS_BIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIGFLOAT) {
- double dMantissa = ConvertBigNumToDouble(pItem->val.expAndMantissa.Mantissa.bigNum);
+ double dMantissa = QCBOR_Private_ConvertBigNumToDouble(pItem->val.expAndMantissa.Mantissa.bigNum);
*pdValue = dMantissa * exp2((double)pItem->val.expAndMantissa.nExponent);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
@@ -5643,7 +5810,7 @@
case QCBOR_TYPE_BIGFLOAT_NEG_BIGNUM:
if(uConvertTypes & QCBOR_CONVERT_TYPE_BIGFLOAT) {
- double dMantissa = -1-ConvertBigNumToDouble(pItem->val.expAndMantissa.Mantissa.bigNum);
+ double dMantissa = -1-QCBOR_Private_ConvertBigNumToDouble(pItem->val.expAndMantissa.Mantissa.bigNum);
*pdValue = dMantissa * exp2((double)pItem->val.expAndMantissa.nExponent);
} else {
return QCBOR_ERR_UNEXPECTED_TYPE;
@@ -5668,16 +5835,17 @@
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDoubleConvertAll(QCBORDecodeContext *pMe,
- uint32_t uConvertTypes,
- double *pdValue)
+ *Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDoubleConvertAll(QCBORDecodeContext *pMe,
+ const uint32_t uConvertTypes,
+ double *pdValue)
{
QCBORItem Item;
- QCBORDecode_GetDoubleConvertInternal(pMe, uConvertTypes, pdValue, &Item);
+ QCBORDecode_Private_GetDoubleConvert(pMe, uConvertTypes, pdValue, &Item);
if(pMe->uLastError == QCBOR_SUCCESS) {
// The above conversion succeeded
@@ -5689,21 +5857,28 @@
return;
}
- pMe->uLastError = (uint8_t)DoubleConvertAll(&Item, uConvertTypes, pdValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_DoubleConvertAll(&Item,
+ uConvertTypes,
+ pdValue);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDoubleConvertAllInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint32_t uConvertTypes,
- double *pdValue)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDoubleConvertAllInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint32_t uConvertTypes,
+ double *pdValue)
{
QCBORItem Item;
- QCBORDecode_GetDoubleConvertInternalInMapN(pMe, nLabel, uConvertTypes, pdValue, &Item);
+ QCBORDecode_Private_GetDoubleConvertInMapN(pMe,
+ nLabel,
+ uConvertTypes,
+ pdValue,
+ &Item);
if(pMe->uLastError == QCBOR_SUCCESS) {
// The above conversion succeeded
@@ -5715,20 +5890,27 @@
return;
}
- pMe->uLastError = (uint8_t)DoubleConvertAll(&Item, uConvertTypes, pdValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_DoubleConvertAll(&Item,
+ uConvertTypes,
+ pdValue);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDoubleConvertAllInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint32_t uConvertTypes,
- double *pdValue)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDoubleConvertAllInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint32_t uConvertTypes,
+ double *pdValue)
{
QCBORItem Item;
- QCBORDecode_GetDoubleConvertInternalInMapSZ(pMe, szLabel, uConvertTypes, pdValue, &Item);
+ QCBORDecode_Private_GetDoubleConvertInMapSZ(pMe,
+ szLabel,
+ uConvertTypes,
+ pdValue,
+ &Item);
if(pMe->uLastError == QCBOR_SUCCESS) {
// The above conversion succeeded
@@ -5740,7 +5922,9 @@
return;
}
- pMe->uLastError = (uint8_t)DoubleConvertAll(&Item, uConvertTypes, pdValue);
+ pMe->uLastError = (uint8_t)QCBOR_Private_DoubleConvertAll(&Item,
+ uConvertTypes,
+ pdValue);
}
#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
@@ -5748,7 +5932,8 @@
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
-static inline UsefulBufC ConvertIntToBigNum(uint64_t uInt, UsefulBuf Buffer)
+static UsefulBufC
+QCBOR_Private_ConvertIntToBigNum(uint64_t uInt, const UsefulBuf Buffer)
{
while((uInt & 0xff00000000000000UL) == 0) {
uInt = uInt << 8;
@@ -5790,9 +5975,9 @@
*/
// TODO: document and see tests for the bug that was fixed by this rewrite
static QCBORError
-MantissaAndExponentTypeHandler(QCBORDecodeContext *pMe,
- const TagSpecification TagSpec,
- QCBORItem *pItem)
+QCBOR_Private_ExpMantissaTypeHandler(QCBORDecodeContext *pMe,
+ const QCBOR_Private_TagSpec TagSpec,
+ QCBORItem *pItem)
{
QCBORError uErr;
@@ -5800,7 +5985,7 @@
* the opening array of an undecoded mantissa and exponent. This
* check will succeed on either, but doesn't say which it was.
*/
- uErr = CheckTagRequirement(TagSpec, pItem);
+ uErr = QCBOR_Private_CheckTagRequirement(TagSpec, pItem);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
@@ -5811,7 +5996,7 @@
* results in a decoded mantissa and exponent in pItem. This is
* the case where there was no tag.
*/
- uErr = QCBORDecode_MantissaAndExponent(pMe, pItem);
+ uErr = QCBORDecode_Private_ExpMantissa(pMe, pItem);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
@@ -5820,7 +6005,7 @@
* fraction or big num. Which of these two depends on what the
* caller wants it decoded as since there is no tag, so fish the
* type out of the TagSpec. */
- pItem->uDataType = MantissaExponentDataType(TagSpec.uTaggedTypes[0], pItem);
+ pItem->uDataType = QCBOR_Private_ExpMantissaDataType(TagSpec.uTaggedTypes[0], pItem);
/* No need to check the type again. All that we need to know was
* that it decoded correctly as a mantissa and exponent. The
@@ -5868,15 +6053,16 @@
* first tier part of the public API. Some functions only
* vary by a TagSpec.
*/
-static void ProcessMantissaAndExponent(QCBORDecodeContext *pMe,
- TagSpecification TagSpec,
- QCBORItem *pItem,
- int64_t *pnMantissa,
- int64_t *pnExponent)
+static void
+QCBOR_Private_ProcessExpMantissa(QCBORDecodeContext *pMe,
+ const QCBOR_Private_TagSpec TagSpec,
+ QCBORItem *pItem,
+ int64_t *pnMantissa,
+ int64_t *pnExponent)
{
QCBORError uErr;
- uErr = MantissaAndExponentTypeHandler(pMe, TagSpec, pItem);
+ uErr = QCBOR_Private_ExpMantissaTypeHandler(pMe, TagSpec, pItem);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
@@ -5894,13 +6080,13 @@
case QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM:
case QCBOR_TYPE_BIGFLOAT_POS_BIGNUM:
*pnExponent = pItem->val.expAndMantissa.nExponent;
- uErr = ConvertPositiveBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, pnMantissa);
+ uErr = QCBOR_Private_ConvertPositiveBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, pnMantissa);
break;
case QCBOR_TYPE_DECIMAL_FRACTION_NEG_BIGNUM:
case QCBOR_TYPE_BIGFLOAT_NEG_BIGNUM:
*pnExponent = pItem->val.expAndMantissa.nExponent;
- uErr = ConvertNegativeBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, pnMantissa);
+ uErr = QCBOR_Private_ConvertNegativeBigNumToSigned(pItem->val.expAndMantissa.Mantissa.bigNum, pnMantissa);
break;
#endif /* QCBOR_DISABLE_TAGS */
@@ -5913,17 +6099,18 @@
}
-static void ProcessMantissaAndExponentBig(QCBORDecodeContext *pMe,
- TagSpecification TagSpec,
- QCBORItem *pItem,
- UsefulBuf BufferForMantissa,
- UsefulBufC *pMantissa,
- bool *pbIsNegative,
- int64_t *pnExponent)
+static void
+QCBOR_Private_ProcessExpMantissaBig(QCBORDecodeContext *pMe,
+ const QCBOR_Private_TagSpec TagSpec,
+ QCBORItem *pItem,
+ const UsefulBuf BufferForMantissa,
+ UsefulBufC *pMantissa,
+ bool *pbIsNegative,
+ int64_t *pnExponent)
{
QCBORError uErr;
- uErr = MantissaAndExponentTypeHandler(pMe, TagSpec, pItem);
+ uErr = QCBOR_Private_ExpMantissaTypeHandler(pMe, TagSpec, pItem);
if(uErr != QCBOR_SUCCESS) {
goto Done;
}
@@ -5945,7 +6132,8 @@
uMantissa = (uint64_t)INT64_MAX+1;
*pbIsNegative = true;
}
- *pMantissa = ConvertIntToBigNum(uMantissa, BufferForMantissa);
+ *pMantissa = QCBOR_Private_ConvertIntToBigNum(uMantissa,
+ BufferForMantissa);
*pnExponent = pItem->val.expAndMantissa.nExponent;
break;
@@ -5976,12 +6164,13 @@
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDecimalFraction(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- int64_t *pnMantissa,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDecimalFraction(QCBORDecodeContext *pMe,
+ const uint8_t uTagRequirement,
+ int64_t *pnMantissa,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -5994,7 +6183,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DECIMAL_FRACTION, QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM,
@@ -6002,18 +6191,23 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponent(pMe, TagSpec, &Item, pnMantissa, pnExponent);
+ QCBOR_Private_ProcessExpMantissa(pMe,
+ TagSpec,
+ &Item,
+ pnMantissa,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDecimalFractionInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- int64_t *pnMantissa,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDecimalFractionInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ int64_t *pnMantissa,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6022,7 +6216,7 @@
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DECIMAL_FRACTION, QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM,
@@ -6030,18 +6224,23 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponent(pMe, TagSpec, &Item, pnMantissa, pnExponent);
+ QCBOR_Private_ProcessExpMantissa(pMe,
+ TagSpec,
+ &Item,
+ pnMantissa,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDecimalFractionInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint8_t uTagRequirement,
- int64_t *pnMantissa,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDecimalFractionInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint8_t uTagRequirement,
+ int64_t *pnMantissa,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6050,7 +6249,7 @@
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DECIMAL_FRACTION, QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM,
@@ -6058,19 +6257,24 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponent(pMe, TagSpec, &Item, pnMantissa, pnExponent);
+ QCBOR_Private_ProcessExpMantissa(pMe,
+ TagSpec,
+ &Item,
+ pnMantissa,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDecimalFractionBig(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBuf MantissaBuffer,
- UsefulBufC *pMantissa,
- bool *pbMantissaIsNegative,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDecimalFractionBig(QCBORDecodeContext *pMe,
+ const uint8_t uTagRequirement,
+ const UsefulBuf MantissaBuffer,
+ UsefulBufC *pMantissa,
+ bool *pbMantissaIsNegative,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6083,7 +6287,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DECIMAL_FRACTION, QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM,
@@ -6091,26 +6295,27 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponentBig(pMe,
- TagSpec,
- &Item,
- MantissaBuffer,
- pMantissa,
- pbMantissaIsNegative,
- pnExponent);
+ QCBOR_Private_ProcessExpMantissaBig(pMe,
+ TagSpec,
+ &Item,
+ MantissaBuffer,
+ pMantissa,
+ pbMantissaIsNegative,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDecimalFractionBigInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBuf BufferForMantissa,
- UsefulBufC *pMantissa,
- bool *pbIsNegative,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDecimalFractionBigInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBuf BufferForMantissa,
+ UsefulBufC *pMantissa,
+ bool *pbIsNegative,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6122,7 +6327,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DECIMAL_FRACTION, QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM,
@@ -6130,26 +6335,27 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponentBig(pMe,
- TagSpec,
- &Item,
- BufferForMantissa,
- pMantissa,
- pbIsNegative,
- pnExponent);
+ QCBOR_Private_ProcessExpMantissaBig(pMe,
+ TagSpec,
+ &Item,
+ BufferForMantissa,
+ pMantissa,
+ pbIsNegative,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetDecimalFractionBigInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBuf BufferForMantissa,
- UsefulBufC *pMantissa,
- bool *pbIsNegative,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetDecimalFractionBigInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBuf BufferForMantissa,
+ UsefulBufC *pMantissa,
+ bool *pbIsNegative,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6161,7 +6367,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_DECIMAL_FRACTION, QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM,
@@ -6169,17 +6375,24 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponentBig(pMe, TagSpec, &Item, BufferForMantissa, pMantissa, pbIsNegative, pnExponent);
+ QCBOR_Private_ProcessExpMantissaBig(pMe,
+ TagSpec,
+ &Item,
+ BufferForMantissa,
+ pMantissa,
+ pbIsNegative,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetBigFloat(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- int64_t *pnMantissa,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetBigFloat(QCBORDecodeContext *pMe,
+ const uint8_t uTagRequirement,
+ int64_t *pnMantissa,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6191,7 +6404,7 @@
pMe->uLastError = (uint8_t)uError;
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BIGFLOAT, QCBOR_TYPE_BIGFLOAT_POS_BIGNUM,
@@ -6199,18 +6412,23 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponent(pMe, TagSpec, &Item, pnMantissa, pnExponent);
+ QCBOR_Private_ProcessExpMantissa(pMe,
+ TagSpec,
+ &Item,
+ pnMantissa,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetBigFloatInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- int64_t *pnMantissa,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetBigFloatInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ int64_t *pnMantissa,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6222,7 +6440,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BIGFLOAT, QCBOR_TYPE_BIGFLOAT_POS_BIGNUM,
@@ -6230,18 +6448,23 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponent(pMe, TagSpec, &Item, pnMantissa, pnExponent);
+ QCBOR_Private_ProcessExpMantissa(pMe,
+ TagSpec,
+ &Item,
+ pnMantissa,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetBigFloatInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint8_t uTagRequirement,
- int64_t *pnMantissa,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetBigFloatInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint8_t uTagRequirement,
+ int64_t *pnMantissa,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6253,7 +6476,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BIGFLOAT, QCBOR_TYPE_BIGFLOAT_POS_BIGNUM,
@@ -6261,19 +6484,24 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponent(pMe, TagSpec, &Item, pnMantissa, pnExponent);
+ QCBOR_Private_ProcessExpMantissa(pMe,
+ TagSpec,
+ &Item,
+ pnMantissa,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetBigFloatBig(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- UsefulBuf MantissaBuffer,
- UsefulBufC *pMantissa,
- bool *pbMantissaIsNegative,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetBigFloatBig(QCBORDecodeContext *pMe,
+ const uint8_t uTagRequirement,
+ const UsefulBuf MantissaBuffer,
+ UsefulBufC *pMantissa,
+ bool *pbMantissaIsNegative,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6286,7 +6514,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BIGFLOAT, QCBOR_TYPE_BIGFLOAT_POS_BIGNUM,
@@ -6294,20 +6522,27 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponentBig(pMe, TagSpec, &Item, MantissaBuffer, pMantissa, pbMantissaIsNegative, pnExponent);
+ QCBOR_Private_ProcessExpMantissaBig(pMe,
+ TagSpec,
+ &Item,
+ MantissaBuffer,
+ pMantissa,
+ pbMantissaIsNegative,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetBigFloatBigInMapN(QCBORDecodeContext *pMe,
- int64_t nLabel,
- uint8_t uTagRequirement,
- UsefulBuf BufferForMantissa,
- UsefulBufC *pMantissa,
- bool *pbIsNegative,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetBigFloatBigInMapN(QCBORDecodeContext *pMe,
+ const int64_t nLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBuf BufferForMantissa,
+ UsefulBufC *pMantissa,
+ bool *pbIsNegative,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6319,7 +6554,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BIGFLOAT, QCBOR_TYPE_BIGFLOAT_POS_BIGNUM,
@@ -6327,26 +6562,27 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponentBig(pMe,
- TagSpec,
- &Item,
- BufferForMantissa,
- pMantissa,
- pbIsNegative,
- pnExponent);
+ QCBOR_Private_ProcessExpMantissaBig(pMe,
+ TagSpec,
+ &Item,
+ BufferForMantissa,
+ pMantissa,
+ pbIsNegative,
+ pnExponent);
}
/*
- Public function, see header qcbor/qcbor_decode.h file
-*/
-void QCBORDecode_GetBigFloatBigInMapSZ(QCBORDecodeContext *pMe,
- const char *szLabel,
- uint8_t uTagRequirement,
- UsefulBuf BufferForMantissa,
- UsefulBufC *pMantissa,
- bool *pbIsNegative,
- int64_t *pnExponent)
+ * Public function, see header qcbor/qcbor_decode.h file
+ */
+void
+QCBORDecode_GetBigFloatBigInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ const uint8_t uTagRequirement,
+ const UsefulBuf BufferForMantissa,
+ UsefulBufC *pMantissa,
+ bool *pbIsNegative,
+ int64_t *pnExponent)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -6358,7 +6594,7 @@
return;
}
- const TagSpecification TagSpec =
+ const QCBOR_Private_TagSpec TagSpec =
{
uTagRequirement,
{QCBOR_TYPE_BIGFLOAT, QCBOR_TYPE_BIGFLOAT_POS_BIGNUM,
@@ -6366,13 +6602,13 @@
{QCBOR_TYPE_ARRAY, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
};
- ProcessMantissaAndExponentBig(pMe,
- TagSpec,
- &Item,
- BufferForMantissa,
- pMantissa,
- pbIsNegative,
- pnExponent);
+ QCBOR_Private_ProcessExpMantissaBig(pMe,
+ TagSpec,
+ &Item,
+ BufferForMantissa,
+ pMantissa,
+ pbIsNegative,
+ pnExponent);
}
#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
diff --git a/src/qcbor_encode.c b/src/qcbor_encode.c
index d5b2a9b..146253d 100644
--- a/src/qcbor_encode.c
+++ b/src/qcbor_encode.c
@@ -1,6 +1,6 @@
/*==============================================================================
Copyright (c) 2016-2018, The Linux Foundation.
- Copyright (c) 2018-2023, Laurence Lundblade.
+ Copyright (c) 2018-2024, Laurence Lundblade.
Copyright (c) 2021, Arm Limited.
All rights reserved.
@@ -72,7 +72,7 @@
* with the type CBOR_MAJOR_TYPE_BYTE_STRING and is tracked here. Byte
* string wrapped CBOR is used by COSE for data that is to be hashed.
*/
-static inline void
+static void
Nesting_Init(QCBORTrackNesting *pNesting)
{
/* Assumes pNesting has been zeroed. */
@@ -83,10 +83,10 @@
pNesting->pCurrentNesting->uMajorType = CBOR_MAJOR_TYPE_ARRAY;
}
-static inline uint8_t
+static uint8_t
Nesting_Increase(QCBORTrackNesting *pNesting,
- uint8_t uMajorType,
- uint32_t uPos)
+ const uint8_t uMajorType,
+ const uint32_t uPos)
{
if(pNesting->pCurrentNesting == &pNesting->pArrays[QCBOR_MAX_ARRAY_NESTING]) {
return QCBOR_ERR_ARRAY_NESTING_TOO_DEEP;
@@ -99,7 +99,7 @@
}
}
-static inline void
+static void
Nesting_Decrease(QCBORTrackNesting *pNesting)
{
if(pNesting->pCurrentNesting > &pNesting->pArrays[0]) {
@@ -107,7 +107,7 @@
}
}
-static inline uint8_t
+static uint8_t
Nesting_Increment(QCBORTrackNesting *pNesting)
{
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
@@ -121,7 +121,7 @@
return QCBOR_SUCCESS;
}
-static inline void
+static void
Nesting_Decrement(QCBORTrackNesting *pNesting)
{
/* No error check for going below 0 here needed because this
@@ -130,7 +130,7 @@
pNesting->pCurrentNesting->uCount--;
}
-static inline uint16_t
+static uint16_t
Nesting_GetCount(QCBORTrackNesting *pNesting)
{
/* The nesting count recorded is always the actual number of
@@ -148,20 +148,20 @@
}
}
-static inline uint32_t
+static uint32_t
Nesting_GetStartPos(QCBORTrackNesting *pNesting)
{
return pNesting->pCurrentNesting->uStart;
}
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
-static inline uint8_t
+static uint8_t
Nesting_GetMajorType(QCBORTrackNesting *pNesting)
{
return pNesting->pCurrentNesting->uMajorType;
}
-static inline bool
+static bool
Nesting_IsInNest(QCBORTrackNesting *pNesting)
{
return pNesting->pCurrentNesting == &pNesting->pArrays[0] ? false : true;
@@ -251,21 +251,23 @@
/*
Public function for initialization. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_Init(QCBOREncodeContext *me, UsefulBuf Storage)
+void
+QCBOREncode_Init(QCBOREncodeContext *pMe, UsefulBuf Storage)
{
- memset(me, 0, sizeof(QCBOREncodeContext));
- UsefulOutBuf_Init(&(me->OutBuf), Storage);
- Nesting_Init(&(me->nesting));
+ memset(pMe, 0, sizeof(QCBOREncodeContext));
+ UsefulOutBuf_Init(&(pMe->OutBuf), Storage);
+ Nesting_Init(&(pMe->nesting));
}
/*
* Public function to encode a CBOR head. See qcbor/qcbor_encode.h
*/
-UsefulBufC QCBOREncode_EncodeHead(UsefulBuf buffer,
- uint8_t uMajorType,
- uint8_t uMinLen,
- uint64_t uArgument)
+UsefulBufC
+QCBOREncode_EncodeHead(UsefulBuf Buffer,
+ uint8_t uMajorType,
+ uint8_t uMinLen,
+ uint64_t uArgument)
{
/*
* == Description of the CBOR Head ==
@@ -412,12 +414,12 @@
* extra. The one extra is needed for this code to work as it does
* a pre-decrement.
*/
- if(buffer.len < QCBOR_HEAD_BUFFER_SIZE) {
+ if(Buffer.len < QCBOR_HEAD_BUFFER_SIZE) {
return NULLUsefulBufC;
}
/* Pointer to last valid byte in the buffer */
- uint8_t * const pBufferEnd = &((uint8_t *)buffer.ptr)[QCBOR_HEAD_BUFFER_SIZE-1];
+ uint8_t * const pBufferEnd = &((uint8_t *)Buffer.ptr)[QCBOR_HEAD_BUFFER_SIZE-1];
/* Point to the last byte and work backwards */
uint8_t *pByte = pBufferEnd;
@@ -500,14 +502,18 @@
/**
* @brief Append the CBOR head, the major type and argument
*
- * @param me Encoder context.
+ * @param pMe Encoder context.
* @param uMajorType Major type to insert.
* @param uArgument The argument (an integer value or a length).
* @param uMinLen The minimum number of bytes for encoding the CBOR argument.
*
* This formats the CBOR "head" and appends it to the output.
*/
-static void AppendCBORHead(QCBOREncodeContext *me, uint8_t uMajorType, uint64_t uArgument, uint8_t uMinLen)
+static void
+QCBOREncode_Private_AppendCBORHead(QCBOREncodeContext *pMe,
+ const uint8_t uMajorType,
+ const uint64_t uArgument,
+ const uint8_t uMinLen)
{
/* A stack buffer large enough for a CBOR head */
UsefulBuf_MAKE_STACK_UB (pBufferForEncodedHead, QCBOR_HEAD_BUFFER_SIZE);
@@ -524,7 +530,7 @@
* security hole introduced.
*/
- UsefulOutBuf_AppendUsefulBuf(&(me->OutBuf), EncodedHead);
+ UsefulOutBuf_AppendUsefulBuf(&(pMe->OutBuf), EncodedHead);
}
@@ -541,8 +547,9 @@
* This is called when closing maps, arrays, byte string wrapping and
* open/close of byte strings.
*/
-bool
-CheckDecreaseNesting(QCBOREncodeContext *pMe, uint8_t uMajorType)
+static bool
+QCBOREncode_Private_CheckDecreaseNesting(QCBOREncodeContext *pMe,
+ const uint8_t uMajorType)
{
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
if(pMe->uError != QCBOR_SUCCESS) {
@@ -578,7 +585,7 @@
/**
* @brief Insert the CBOR head for a map, array or wrapped bstr
*
- * @param me QCBOR encoding context.
+ * @param pMe QCBOR encoding context.
* @param uMajorType One of CBOR_MAJOR_TYPE_XXXX.
* @param uLen The length of the data item.
*
@@ -586,9 +593,12 @@
* the position. This function goes back to that position and inserts
* the CBOR Head with the major type and length.
*/
-static void InsertCBORHead(QCBOREncodeContext *me, uint8_t uMajorType, size_t uLen)
+static void
+QCBOREncode_Private_InsertCBORHead(QCBOREncodeContext *pMe,
+ uint8_t uMajorType,
+ size_t uLen)
{
- if(CheckDecreaseNesting(me, uMajorType)) {
+ if(QCBOREncode_Private_CheckDecreaseNesting(pMe, uMajorType)) {
return;
}
@@ -610,11 +620,11 @@
* UsefulOutBuf_InsertUsefulBuf() will do nothing so there is no
* security hole introduced.
*/
- UsefulOutBuf_InsertUsefulBuf(&(me->OutBuf),
+ UsefulOutBuf_InsertUsefulBuf(&(pMe->OutBuf),
EncodedHead,
- Nesting_GetStartPos(&(me->nesting)));
+ Nesting_GetStartPos(&(pMe->nesting)));
- Nesting_Decrease(&(me->nesting));
+ Nesting_Decrease(&(pMe->nesting));
}
@@ -626,7 +636,8 @@
* This is mostly a separate function to make code more readable and
* to have fewer occurrences of #ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
*/
-static inline void IncrementMapOrArrayCount(QCBOREncodeContext *pMe)
+static void
+QCBOREncode_Private_IncrementMapOrArrayCount(QCBOREncodeContext *pMe)
{
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
if(pMe->uError == QCBOR_SUCCESS) {
@@ -641,18 +652,23 @@
/*
* Public functions for adding unsigned integers. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_AddUInt64(QCBOREncodeContext *me, uint64_t uValue)
+void
+QCBOREncode_AddUInt64(QCBOREncodeContext *pMe, const uint64_t uValue)
{
- AppendCBORHead(me, CBOR_MAJOR_TYPE_POSITIVE_INT, uValue, 0);
+ QCBOREncode_Private_AppendCBORHead(pMe,
+ CBOR_MAJOR_TYPE_POSITIVE_INT,
+ uValue,
+ 0);
- IncrementMapOrArrayCount(me);
+ QCBOREncode_Private_IncrementMapOrArrayCount(pMe);
}
/*
* Public functions for adding signed integers. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_AddInt64(QCBOREncodeContext *me, int64_t nNum)
+void
+QCBOREncode_AddInt64(QCBOREncodeContext *pMe, const int64_t nNum)
{
uint8_t uMajorType;
uint64_t uValue;
@@ -670,17 +686,28 @@
uValue = (uint64_t)nNum;
uMajorType = CBOR_MAJOR_TYPE_POSITIVE_INT;
}
- AppendCBORHead(me, uMajorType, uValue, 0);
+ QCBOREncode_Private_AppendCBORHead(pMe, uMajorType, uValue, 0);
- IncrementMapOrArrayCount(me);
+ QCBOREncode_Private_IncrementMapOrArrayCount(pMe);
}
-/*
- * Semi-private function. It is exposed to user of the interface, but
- * one of its inline wrappers will usually be called instead of this.
+/**
+ * @brief Semi-private method to add a buffer full of bytes to encoded output.
*
- * See qcbor/qcbor_encode.h
+ * @param[in] pMe The encoding context to add the integer to.
+ * @param[in] uMajorType The CBOR major type of the bytes.
+ * @param[in] Bytes The bytes to add.
+ *
+ * Use QCBOREncode_AddText() or QCBOREncode_AddBytes() or
+ * QCBOREncode_AddEncoded() instead. They are inline functions that
+ * call this and supply the correct major type. This function is
+ * public to make the inline functions work to keep the overall code
+ * size down and because the C language has no way to make it private.
+ *
+ * If this is called the major type should be @c CBOR_MAJOR_TYPE_TEXT_STRING,
+ * @c CBOR_MAJOR_TYPE_BYTE_STRING or @c CBOR_MAJOR_NONE_TYPE_RAW. The
+ * last one is special for adding already-encoded CBOR.
*
* This does the work of adding actual strings bytes to the CBOR
* output (as opposed to adding numbers and opening / closing
@@ -697,7 +724,10 @@
* fourth just adds the head for the very special case of
* QCBOREncode_AddBytesLenOnly().
*/
-void QCBOREncode_AddBuffer(QCBOREncodeContext *me, uint8_t uMajorType, UsefulBufC Bytes)
+void
+QCBOREncode_Private_AddBuffer(QCBOREncodeContext *pMe,
+ const uint8_t uMajorType,
+ const UsefulBufC Bytes)
{
/* If it is not Raw CBOR, add the type and the length */
if(uMajorType != CBOR_MAJOR_NONE_TYPE_RAW) {
@@ -705,48 +735,64 @@
if(uRealMajorType == CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY) {
uRealMajorType = CBOR_MAJOR_TYPE_BYTE_STRING;
}
- AppendCBORHead(me, uRealMajorType, Bytes.len, 0);
+ QCBOREncode_Private_AppendCBORHead(pMe, uRealMajorType, Bytes.len, 0);
}
if(uMajorType != CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY) {
/* Actually add the bytes */
- UsefulOutBuf_AppendUsefulBuf(&(me->OutBuf), Bytes);
+ UsefulOutBuf_AppendUsefulBuf(&(pMe->OutBuf), Bytes);
}
- IncrementMapOrArrayCount(me);
+ QCBOREncode_Private_IncrementMapOrArrayCount(pMe);
}
/*
* Public functions for adding a tag. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_AddTag(QCBOREncodeContext *me, uint64_t uTag)
+void
+QCBOREncode_AddTag(QCBOREncodeContext *pMe, const uint64_t uTag)
{
- AppendCBORHead(me, CBOR_MAJOR_TYPE_TAG, uTag, 0);
+ QCBOREncode_Private_AppendCBORHead(pMe, CBOR_MAJOR_TYPE_TAG, uTag, 0);
}
-/*
- * Semi-private function. It is exposed to user of the interface, but
- * one of its inline wrappers will usually be called instead of this.
+/**
+ * @brief Semi-private method to add simple types.
*
- * See header qcbor/qcbor_encode.h
+ * @param[in] pMe The encoding context to add the simple value to.
+ * @param[in] uMinLen Minimum encoding size for uNum. Usually 0.
+ * @param[in] uNum One of CBOR_SIMPLEV_FALSE through _UNDEF or other.
+ *
+ * This is used to add simple types like true and false.
+ *
+ * Call QCBOREncode_AddBool(), QCBOREncode_AddNULL(),
+ * QCBOREncode_AddUndef() instead of this.
+ *
+ * This function can add simple values that are not defined by CBOR
+ * yet. This expansion point in CBOR should not be used unless they are
+ * standardized.
+ *
+ * Error handling is the same as QCBOREncode_AddInt64().
*/
-void QCBOREncode_AddType7(QCBOREncodeContext *me, uint8_t uMinLen, uint64_t uNum)
+void
+QCBOREncode_Private_AddType7(QCBOREncodeContext *pMe,
+ const uint8_t uMinLen,
+ const uint64_t uNum)
{
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
- if(me->uError == QCBOR_SUCCESS) {
+ if(pMe->uError == QCBOR_SUCCESS) {
if(uNum >= CBOR_SIMPLEV_RESERVED_START && uNum <= CBOR_SIMPLEV_RESERVED_END) {
- me->uError = QCBOR_ERR_ENCODE_UNSUPPORTED;
+ pMe->uError = QCBOR_ERR_ENCODE_UNSUPPORTED;
return;
}
}
#endif /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
/* AppendCBORHead() does endian swapping for the float / double */
- AppendCBORHead(me, CBOR_MAJOR_TYPE_SIMPLE, uNum, uMinLen);
+ QCBOREncode_Private_AppendCBORHead(pMe, CBOR_MAJOR_TYPE_SIMPLE, uNum, uMinLen);
- IncrementMapOrArrayCount(me);
+ QCBOREncode_Private_IncrementMapOrArrayCount(pMe);
}
@@ -754,25 +800,27 @@
/*
* Public functions for adding a double. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_AddDoubleNoPreferred(QCBOREncodeContext *me, double dNum)
+void
+QCBOREncode_AddDoubleNoPreferred(QCBOREncodeContext *pMe, const double dNum)
{
- QCBOREncode_AddType7(me,
- sizeof(uint64_t),
- UsefulBufUtil_CopyDoubleToUint64(dNum));
+ QCBOREncode_Private_AddType7(pMe,
+ sizeof(uint64_t),
+ UsefulBufUtil_CopyDoubleToUint64(dNum));
}
/*
* Public functions for adding a double. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_AddDouble(QCBOREncodeContext *me, double dNum)
+void
+QCBOREncode_AddDouble(QCBOREncodeContext *pMe, const double dNum)
{
#ifndef QCBOR_DISABLE_PREFERRED_FLOAT
const IEEE754_union uNum = IEEE754_DoubleToSmaller(dNum, true);
- QCBOREncode_AddType7(me, (uint8_t)uNum.uSize, uNum.uValue);
+ QCBOREncode_Private_AddType7(pMe, (uint8_t)uNum.uSize, uNum.uValue);
#else /* QCBOR_DISABLE_PREFERRED_FLOAT */
- QCBOREncode_AddDoubleNoPreferred(me, dNum);
+ QCBOREncode_AddDoubleNoPreferred(pMe, dNum);
#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
}
@@ -806,48 +854,70 @@
/*
* Public functions for adding a float. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_AddFloatNoPreferred(QCBOREncodeContext *me, float fNum)
+void
+QCBOREncode_AddFloatNoPreferred(QCBOREncodeContext *pMe, const float fNum)
{
- QCBOREncode_AddType7(me,
- sizeof(uint32_t),
- UsefulBufUtil_CopyFloatToUint32(fNum));
+ QCBOREncode_Private_AddType7(pMe,
+ sizeof(uint32_t),
+ UsefulBufUtil_CopyFloatToUint32(fNum));
}
/*
* Public functions for adding a float. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_AddFloat(QCBOREncodeContext *me, float fNum)
+void
+QCBOREncode_AddFloat(QCBOREncodeContext *pMe, const float fNum)
{
#ifndef QCBOR_DISABLE_PREFERRED_FLOAT
const IEEE754_union uNum = IEEE754_SingleToHalf(fNum);
- QCBOREncode_AddType7(me, (uint8_t)uNum.uSize, uNum.uValue);
+ QCBOREncode_Private_AddType7(pMe, (uint8_t)uNum.uSize, uNum.uValue);
#else /* QCBOR_DISABLE_PREFERRED_FLOAT */
- QCBOREncode_AddFloatNoPreferred(me, fNum);
+ QCBOREncode_AddFloatNoPreferred(pMe, fNum);
#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
}
#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
-/*
- * Semi-public function. It is exposed to the user of the interface,
- * but one of the inline wrappers will usually be called rather than
- * this.
+/**
+ * @brief Semi-private method to add bigfloats and decimal fractions.
*
- * See qcbor/qcbor_encode.h
+ * @param[in] pMe The encoding context to add the value to.
+ * @param[in] uTag The type 6 tag indicating what this is to be.
+ * @param[in] BigNumMantissa Is @ref NULLUsefulBufC if mantissa is an
+ * @c int64_t or the actual big number mantissa
+ * if not.
+ * @param[in] bBigNumIsNegative This is @c true if the big number is negative.
+ * @param[in] nMantissa The @c int64_t mantissa if it is not a big number.
+ * @param[in] nExponent The exponent.
*
- * Improvement: create another version of this that only takes a big
- * number mantissa and converts the output to a type 0 or 1 integer
- * when mantissa is small enough.
+ * This outputs either the @ref CBOR_TAG_DECIMAL_FRACTION or
+ * @ref CBOR_TAG_BIGFLOAT tag. if @c uTag is @ref CBOR_TAG_INVALID64,
+ * then this outputs the "borrowed" content format.
+ *
+ * The tag content output by this is an array with two members, the
+ * exponent and then the mantissa. The mantissa can be either a big
+ * number or an @c int64_t.
+ *
+ * This implementation cannot output an exponent further from 0 than
+ * @c INT64_MAX.
+ *
+ * To output a mantissa that is between INT64_MAX and UINT64_MAX from 0,
+ * it must be as a big number.
+ *
+ * Typically, QCBOREncode_AddDecimalFraction(), QCBOREncode_AddBigFloat(),
+ * QCBOREncode_AddDecimalFractionBigNum() or QCBOREncode_AddBigFloatBigNum()
+ * is called instead of this.
*/
-void QCBOREncode_AddExponentAndMantissa(QCBOREncodeContext *pMe,
- uint64_t uTag,
- UsefulBufC BigNumMantissa,
- bool bBigNumIsNegative,
- int64_t nMantissa,
- int64_t nExponent)
+void
+QCBOREncode_Private_AddExpMantissa(QCBOREncodeContext *pMe,
+ const uint64_t uTag,
+ const UsefulBufC BigNumMantissa,
+ const bool bBigNumIsNegative,
+ const int64_t nMantissa,
+ const int64_t nExponent)
{
/* This is for encoding either a big float or a decimal fraction,
* both of which are an array of two items, an exponent and a
@@ -874,17 +944,21 @@
#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
-/*
- * Semi-public function. It is exposed to the user of the interface,
- * but one of the inline wrappers will usually be called rather than
- * this.
+/**
+ * @brief Semi-private method to open a map, array or bstr-wrapped CBOR
*
- * See qcbor/qcbor_encode.h
+ * @param[in] pMe The context to add to.
+ * @param[in] uMajorType The major CBOR type to close
+ *
+ * Call QCBOREncode_OpenArray(), QCBOREncode_OpenMap() or
+ * QCBOREncode_BstrWrap() instead of this.
*/
-void QCBOREncode_OpenMapOrArray(QCBOREncodeContext *me, uint8_t uMajorType)
+void
+QCBOREncode_Private_OpenMapOrArray(QCBOREncodeContext *pMe,
+ const uint8_t uMajorType)
{
/* Add one item to the nesting level we are in for the new map or array */
- IncrementMapOrArrayCount(me);
+ QCBOREncode_Private_IncrementMapOrArrayCount(pMe);
/* The offset where the length of an array or map will get written
* is stored in a uint32_t, not a size_t to keep stack usage
@@ -894,7 +968,7 @@
* past the 4GB mark, but the public interface says that the
* maximum is 4GB to keep the discussion simpler.
*/
- size_t uEndPosition = UsefulOutBuf_GetEndPosition(&(me->OutBuf));
+ size_t uEndPosition = UsefulOutBuf_GetEndPosition(&(pMe->OutBuf));
/* QCBOR_MAX_ARRAY_OFFSET is slightly less than UINT32_MAX so this
* code can run on a 32-bit machine and tests can pass on a 32-bit
@@ -903,43 +977,54 @@
* size detection would be needed reducing portability.
*/
if(uEndPosition >= QCBOR_MAX_ARRAY_OFFSET) {
- me->uError = QCBOR_ERR_BUFFER_TOO_LARGE;
+ pMe->uError = QCBOR_ERR_BUFFER_TOO_LARGE;
} else {
/* Increase nesting level because this is a map or array. Cast
* from size_t to uin32_t is safe because of check above.
*/
- me->uError = Nesting_Increase(&(me->nesting), uMajorType, (uint32_t)uEndPosition);
+ pMe->uError = Nesting_Increase(&(pMe->nesting), uMajorType, (uint32_t)uEndPosition);
}
}
-/*
- * Semi-public function. It is exposed to the user of the interface,
- * but one of the inline wrappers will usually be called rather than
- * this.
+/**
+ * @brief Semi-private method to open a map, array with indefinite length
*
- * See qcbor/qcbor_encode.h
+ * @param[in] pMe The context to add to.
+ * @param[in] uMajorType The major CBOR type to close
+ *
+ * Call QCBOREncode_OpenArrayIndefiniteLength() or
+ * QCBOREncode_OpenMapIndefiniteLength() instead of this.
*/
-void QCBOREncode_OpenMapOrArrayIndefiniteLength(QCBOREncodeContext *me, uint8_t uMajorType)
+void
+QCBOREncode_Private_OpenMapOrArrayIndefiniteLength(QCBOREncodeContext *pMe,
+ const uint8_t uMajorType)
{
/* Insert the indefinite length marker (0x9f for arrays, 0xbf for maps) */
- AppendCBORHead(me, uMajorType, 0, 0);
+ QCBOREncode_Private_AppendCBORHead(pMe, uMajorType, 0, 0);
/* Call the definite-length opener just to do the bookkeeping for
* nesting. It will record the position of the opening item in the
* encoded output but this is not used when closing this open.
*/
- QCBOREncode_OpenMapOrArray(me, uMajorType);
+ QCBOREncode_Private_OpenMapOrArray(pMe, uMajorType);
}
-/*
- * Public functions for closing arrays and maps. See qcbor/qcbor_encode.h
+/**
+ * @brief Semi-private method to close a map, array or bstr wrapped CBOR
+ *
+ * @param[in] pMe The context to add to.
+ * @param[in] uMajorType The major CBOR type to close.
+ *
+ * Call QCBOREncode_CloseArray() or QCBOREncode_CloseMap() instead of this.
*/
-void QCBOREncode_CloseMapOrArray(QCBOREncodeContext *me, uint8_t uMajorType)
+void
+QCBOREncode_Private_CloseMapOrArray(QCBOREncodeContext *pMe,
+ const uint8_t uMajorType)
{
- InsertCBORHead(me, uMajorType, Nesting_GetCount(&(me->nesting)));
+ QCBOREncode_Private_InsertCBORHead(pMe, uMajorType, Nesting_GetCount(&(pMe->nesting)));
}
@@ -1032,7 +1117,7 @@
* Recursive, but stack usage is light and encoding depth limit
*/
static QCBORError
-QCBOREncodePriv_ConsumeNext(UsefulInputBuf *pInBuf)
+QCBOR_Private_ConsumeNext(UsefulInputBuf *pInBuf)
{
int nMajor;
uint64_t uArgument;
@@ -1062,13 +1147,13 @@
case CBOR_MAJOR_TYPE_TEXT_STRING:
if(nAdditional == LEN_IS_INDEFINITE) {
/* Segments of indefinite length */
- while(QCBOREncodePriv_ConsumeNext(pInBuf) == 0);
+ while(QCBOR_Private_ConsumeNext(pInBuf) == 0);
}
(void)UsefulInputBuf_GetBytes(pInBuf, uArgument);
break;
case CBOR_MAJOR_TYPE_TAG:
- QCBOREncodePriv_ConsumeNext(pInBuf);
+ QCBOR_Private_ConsumeNext(pInBuf);
break;
case CBOR_MAJOR_TYPE_MAP:
@@ -1080,7 +1165,7 @@
uItemCount = UINT16_MAX;
}
for(i = uItemCount; i > 0; i--) {
- if(QCBOREncodePriv_ConsumeNext(pInBuf)) {
+ if(QCBOR_Private_ConsumeNext(pInBuf)) {
/* End of indefinite length */
break;
}
@@ -1106,7 +1191,7 @@
* in case of bugs here, but it is OK to report end of input on error.
*/
static uint32_t
-QCBOREncodePriv_DecodeNextInMap(QCBOREncodeContext *pMe, uint32_t uStart)
+QCBOREncode_Private_DecodeNextInMap(QCBOREncodeContext *pMe, uint32_t uStart)
{
UsefulInputBuf InBuf;
UsefulBufC EncodedMapBytes;
@@ -1120,11 +1205,11 @@
UsefulInputBuf_Init(&InBuf, EncodedMapBytes);
/* This is always used on maps, so consume two, the label and the value */
- uCBORError = QCBOREncodePriv_ConsumeNext(&InBuf);
+ uCBORError = QCBOR_Private_ConsumeNext(&InBuf);
if(uCBORError) {
return 0;
}
- uCBORError = QCBOREncodePriv_ConsumeNext(&InBuf);
+ uCBORError = QCBOR_Private_ConsumeNext(&InBuf);
if(uCBORError) {
return 0;
}
@@ -1146,7 +1231,7 @@
* UsefulOutBuf.
*/
static void
-QCBOREncodePriv_SortMap(QCBOREncodeContext *pMe, uint32_t uStart)
+QCBOREncode_Private_SortMap(QCBOREncodeContext *pMe, uint32_t uStart)
{
bool bSwapped;
int nComparison;
@@ -1174,7 +1259,7 @@
* swapped.
*/
do {
- uLen1 = QCBOREncodePriv_DecodeNextInMap(pMe, uStart);
+ uLen1 = QCBOREncode_Private_DecodeNextInMap(pMe, uStart);
if(uLen1 == 0) {
/* It's an empty map. Nothing to do. */
break;
@@ -1184,7 +1269,7 @@
bSwapped = false;
while(1) {
- uLen2 = QCBOREncodePriv_DecodeNextInMap(pMe, uStart2);
+ uLen2 = QCBOREncode_Private_DecodeNextInMap(pMe, uStart2);
if(uLen2 == 0) {
break;
}
@@ -1216,9 +1301,9 @@
* items we are about to sort.
*/
uStart = Nesting_GetStartPos(&(pMe->nesting));
- QCBOREncodePriv_SortMap(pMe, uStart);
+ QCBOREncode_Private_SortMap(pMe, uStart);
- QCBOREncode_CloseMapOrArray(pMe, CBOR_MAJOR_TYPE_MAP);
+ QCBOREncode_Private_InsertCBORHead(pMe, CBOR_MAJOR_TYPE_MAP, Nesting_GetCount(&(pMe->nesting)));
}
@@ -1230,19 +1315,22 @@
uint32_t uStart;
uStart = Nesting_GetStartPos(&(pMe->nesting));
- QCBOREncodePriv_SortMap(pMe, uStart);
+ QCBOREncode_Private_SortMap(pMe, uStart);
- QCBOREncode_CloseMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN);
+ QCBOREncode_Private_CloseMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN);
}
/*
* Public functions for closing bstr wrapping. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_CloseBstrWrap2(QCBOREncodeContext *me, bool bIncludeCBORHead, UsefulBufC *pWrappedCBOR)
+void
+QCBOREncode_CloseBstrWrap2(QCBOREncodeContext *pMe,
+ const bool bIncludeCBORHead,
+ UsefulBufC *pWrappedCBOR)
{
- const size_t uInsertPosition = Nesting_GetStartPos(&(me->nesting));
- const size_t uEndPosition = UsefulOutBuf_GetEndPosition(&(me->OutBuf));
+ const size_t uInsertPosition = Nesting_GetStartPos(&(pMe->nesting));
+ const size_t uEndPosition = UsefulOutBuf_GetEndPosition(&(pMe->OutBuf));
/* This subtraction can't go negative because the UsefulOutBuf
* always only grows and never shrinks. UsefulOutBut itself also
@@ -1252,7 +1340,7 @@
const size_t uBstrLen = uEndPosition - uInsertPosition;
/* Actually insert */
- InsertCBORHead(me, CBOR_MAJOR_TYPE_BYTE_STRING, uBstrLen);
+ QCBOREncode_Private_InsertCBORHead(pMe, CBOR_MAJOR_TYPE_BYTE_STRING, uBstrLen);
if(pWrappedCBOR) {
/* Return pointer and length to the enclosed encoded CBOR. The
@@ -1265,10 +1353,10 @@
size_t uStartOfNew = uInsertPosition;
if(!bIncludeCBORHead) {
/* Skip over the CBOR head to just get the inserted bstr */
- const size_t uNewEndPosition = UsefulOutBuf_GetEndPosition(&(me->OutBuf));
+ const size_t uNewEndPosition = UsefulOutBuf_GetEndPosition(&(pMe->OutBuf));
uStartOfNew += uNewEndPosition - uEndPosition;
}
- const UsefulBufC PartialResult = UsefulOutBuf_OutUBuf(&(me->OutBuf));
+ const UsefulBufC PartialResult = UsefulOutBuf_OutUBuf(&(pMe->OutBuf));
*pWrappedCBOR = UsefulBuf_Tail(PartialResult, uStartOfNew);
}
}
@@ -1277,9 +1365,10 @@
/*
* Public function for canceling a bstr wrap. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_CancelBstrWrap(QCBOREncodeContext *pMe)
+void
+QCBOREncode_CancelBstrWrap(QCBOREncodeContext *pMe)
{
- if(CheckDecreaseNesting(pMe, CBOR_MAJOR_TYPE_BYTE_STRING)) {
+ if(QCBOREncode_Private_CheckDecreaseNesting(pMe, CBOR_MAJOR_TYPE_BYTE_STRING)) {
return;
}
@@ -1307,7 +1396,8 @@
/*
* Public function for opening a byte string. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_OpenBytes(QCBOREncodeContext *pMe, UsefulBuf *pPlace)
+void
+QCBOREncode_OpenBytes(QCBOREncodeContext *pMe, UsefulBuf *pPlace)
{
*pPlace = UsefulOutBuf_GetOutPlace(&(pMe->OutBuf));
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
@@ -1319,14 +1409,15 @@
}
#endif /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
- QCBOREncode_OpenMapOrArray(pMe, CBOR_MAJOR_NONE_TYPE_OPEN_BSTR);
+ QCBOREncode_Private_OpenMapOrArray(pMe, CBOR_MAJOR_NONE_TYPE_OPEN_BSTR);
}
/*
* Public function for closing a byte string. See qcbor/qcbor_encode.h
*/
-void QCBOREncode_CloseBytes(QCBOREncodeContext *pMe, const size_t uAmount)
+void
+QCBOREncode_CloseBytes(QCBOREncodeContext *pMe, const size_t uAmount)
{
UsefulOutBuf_Advance(&(pMe->OutBuf), uAmount);
if(UsefulOutBuf_GetError(&(pMe->OutBuf))) {
@@ -1334,21 +1425,29 @@
return;
}
- InsertCBORHead(pMe, CBOR_MAJOR_NONE_TYPE_OPEN_BSTR, uAmount);
+ QCBOREncode_Private_InsertCBORHead(pMe, CBOR_MAJOR_NONE_TYPE_OPEN_BSTR, uAmount);
}
-/*
- * Public function for closing arrays and maps. See qcbor/qcbor_encode.h
+/**
+ * @brief Semi-private method to close a map, array with indefinite length
+ *
+ * @param[in] pMe The context to add to.
+ * @param[in] uMajorType The major CBOR type to close.
+ *
+ * Call QCBOREncode_CloseArrayIndefiniteLength() or
+ * QCBOREncode_CloseMapIndefiniteLength() instead of this.
*/
-void QCBOREncode_CloseMapOrArrayIndefiniteLength(QCBOREncodeContext *pMe, uint8_t uMajorType)
+void
+QCBOREncode_Private_CloseMapOrArrayIndefiniteLength(QCBOREncodeContext *pMe,
+ const uint8_t uMajorType)
{
- if(CheckDecreaseNesting(pMe, uMajorType)) {
+ if(QCBOREncode_Private_CheckDecreaseNesting(pMe, uMajorType)) {
return;
}
/* Append the break marker (0xff for both arrays and maps) */
- AppendCBORHead(pMe, CBOR_MAJOR_NONE_TYPE_SIMPLE_BREAK, CBOR_SIMPLE_BREAK, 0);
+ QCBOREncode_Private_AppendCBORHead(pMe, CBOR_MAJOR_NONE_TYPE_SIMPLE_BREAK, CBOR_SIMPLE_BREAK, 0);
Nesting_Decrease(&(pMe->nesting));
}
@@ -1356,22 +1455,23 @@
/*
* Public function to finish and get the encoded result. See qcbor/qcbor_encode.h
*/
-QCBORError QCBOREncode_Finish(QCBOREncodeContext *me, UsefulBufC *pEncodedCBOR)
+QCBORError
+QCBOREncode_Finish(QCBOREncodeContext *pMe, UsefulBufC *pEncodedCBOR)
{
- QCBORError uReturn = QCBOREncode_GetErrorState(me);
+ QCBORError uReturn = QCBOREncode_GetErrorState(pMe);
if(uReturn != QCBOR_SUCCESS) {
goto Done;
}
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
- if(Nesting_IsInNest(&(me->nesting))) {
+ if(Nesting_IsInNest(&(pMe->nesting))) {
uReturn = QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN;
goto Done;
}
#endif /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
- *pEncodedCBOR = UsefulOutBuf_OutUBuf(&(me->OutBuf));
+ *pEncodedCBOR = UsefulOutBuf_OutUBuf(&(pMe->OutBuf));
Done:
return uReturn;
@@ -1381,11 +1481,12 @@
/*
* Public functions to get size of the encoded result. See qcbor/qcbor_encode.h
*/
-QCBORError QCBOREncode_FinishGetSize(QCBOREncodeContext *me, size_t *puEncodedLen)
+QCBORError
+QCBOREncode_FinishGetSize(QCBOREncodeContext *pMe, size_t *puEncodedLen)
{
UsefulBufC Enc;
- QCBORError nReturn = QCBOREncode_Finish(me, &Enc);
+ QCBORError nReturn = QCBOREncode_Finish(pMe, &Enc);
if(nReturn == QCBOR_SUCCESS) {
*puEncodedLen = Enc.len;
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 7ccfc4e..0abbb72 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -1,6 +1,6 @@
/*==============================================================================
Copyright (c) 2016-2018, The Linux Foundation.
- Copyright (c) 2018-2023, Laurence Lundblade.
+ Copyright (c) 2018-2024, Laurence Lundblade.
Copyright (c) 2022, Arm Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -96,13 +96,9 @@
#endif
-#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
/*
Returns 0 if UsefulBufs are equal
Returns 1000000 + offeset if they are not equal.
-
-
-
*/
struct UBCompareDiagnostic {
uint8_t uActual;
@@ -130,7 +126,6 @@
return 0;
}
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
// One big buffer that is used by all the tests to encode into
@@ -602,13 +597,13 @@
QCBOREncode_CloseMap(pECtx);
/* true / false ... */
- QCBOREncode_AddSimple(pECtx, CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddUndef(pECtx);
QCBOREncode_OpenMap(pECtx);
QCBOREncode_AddSZString(pECtx, "dare");
QCBOREncode_AddTag(pECtx, 66);
QCBOREncode_AddBool(pECtx, true);
QCBOREncode_AddBoolToMap(pECtx, "uu", false);
- QCBOREncode_AddSimpleToMapN(pECtx, 737634, CBOR_SIMPLEV_NULL);
+ QCBOREncode_AddNULLToMapN(pECtx, 737634);
QCBOREncode_CloseMap(pECtx);
/* opening an array */
@@ -643,17 +638,17 @@
QCBOREncode_OpenMap(pECtx);
QCBOREncode_AddSZString(pECtx, "s1");
QCBOREncode_AddTag(pECtx, 88);
- QCBOREncode_AddSimple(pECtx, 255);
- QCBOREncode_AddSimpleToMap(pECtx, "s2", 0);
+ QCBOREncode_Private_AddSimple(pECtx, 255);
+ QCBOREncode_Private_AddSimpleToMap(pECtx, "s2", 0);
QCBOREncode_AddSZString(pECtx, "s3");
QCBOREncode_AddTag(pECtx, 88);
- QCBOREncode_AddSimple(pECtx, 33);
+ QCBOREncode_Private_AddSimple(pECtx, 33);
QCBOREncode_AddInt64(pECtx, 88378374); // label before tag
QCBOREncode_AddTag(pECtx, 88);
- QCBOREncode_AddSimple(pECtx, 255);
+ QCBOREncode_Private_AddSimple(pECtx, 255);
QCBOREncode_AddInt64(pECtx, 89); // label before tag
QCBOREncode_AddTag(pECtx, 88);
- QCBOREncode_AddSimple(pECtx, 19);
+ QCBOREncode_Private_AddSimple(pECtx, 19);
QCBOREncode_CloseMap(pECtx);
/* UUIDs */
@@ -912,14 +907,14 @@
QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
QCBOREncode_OpenArray(&ECtx);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_TRUE);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_FALSE);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_NULL);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddBool(&ECtx, true);
+ QCBOREncode_AddBool(&ECtx, false);
+ QCBOREncode_AddNULL(&ECtx);
+ QCBOREncode_AddUndef(&ECtx);
QCBOREncode_OpenMap(&ECtx);
- QCBOREncode_AddSimpleToMap(&ECtx, "UNDef", CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddUndefToMap(&ECtx, "UNDef");
QCBOREncode_CloseMap(&ECtx);
QCBOREncode_CloseArray(&ECtx);
@@ -959,14 +954,14 @@
QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
QCBOREncode_OpenArrayIndefiniteLength(&ECtx);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_TRUE);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_FALSE);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_NULL);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddBool(&ECtx, true);
+ QCBOREncode_AddBool(&ECtx, false);
+ QCBOREncode_AddNULL(&ECtx);
+ QCBOREncode_AddUndef(&ECtx);
QCBOREncode_OpenMapIndefiniteLength(&ECtx);
- QCBOREncode_AddSimpleToMap(&ECtx, "UNDef", CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddUndefToMap(&ECtx, "UNDef");
QCBOREncode_CloseMapIndefiniteLength(&ECtx);
QCBOREncode_CloseArrayIndefiniteLength(&ECtx);
@@ -1647,7 +1642,7 @@
// The result: 0 if scan happened and found nothing; 1 if it happened and
// found something wrong; 2 if it didn't happen
- QCBOREncode_AddSimpleToMap(&ECtx, "integrity", uRResult);
+ QCBOREncode_Private_AddSimpleToMap(&ECtx, "integrity", uRResult);
// Add the diagnostic code
QCBOREncode_AddSZStringToMap(&ECtx, "type", szType);
@@ -2651,7 +2646,7 @@
/* ------ QCBOR_ERR_UNSUPPORTED -------- */
QCBOREncode_Init(&EC, Large);
QCBOREncode_OpenArray(&EC);
- QCBOREncode_AddSimple(&EC, 24); /* CBOR_SIMPLEV_RESERVED_START */
+ QCBOREncode_Private_AddSimple(&EC, 24); /* CBOR_SIMPLEV_RESERVED_START */
uErr = QCBOREncode_FinishGetSize(&EC, &xx);
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
if(uErr != QCBOR_ERR_ENCODE_UNSUPPORTED) {
@@ -2666,7 +2661,7 @@
QCBOREncode_Init(&EC, Large);
QCBOREncode_OpenArray(&EC);
- QCBOREncode_AddSimple(&EC, 31); /* CBOR_SIMPLEV_RESERVED_END */
+ QCBOREncode_Private_AddSimple(&EC, 31); /* CBOR_SIMPLEV_RESERVED_END */
uErr = QCBOREncode_FinishGetSize(&EC, &xx);
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
if(uErr != QCBOR_ERR_ENCODE_UNSUPPORTED) {
@@ -3109,9 +3104,7 @@
static const uint8_t spBasic[] = {
0xA4, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04};
- if(UsefulBuf_CompareWithDiagnostic(EncodedAndSorted,
- UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spBasic),
- &CompareDiagnostics)) {
+ if(UsefulBuf_Compare(EncodedAndSorted, UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spBasic))) {
return 12;
}
@@ -3271,8 +3264,12 @@
QCBOREncode_Init(&EC, TestBuf);
QCBOREncode_OpenMap(&EC);
+ /* Adding labels directly rather than AddToMap functions */
+
+#ifndef USEFULBUF_DISABLE_ALL_FLOAT
QCBOREncode_AddDouble(&EC, 8.77);
QCBOREncode_AddInt64(&EC, 7);
+#endif /* QCBOR_DISABLE_ALL_FLOAT */
QCBOREncode_AddBool(&EC, true);
QCBOREncode_AddInt64(&EC, 6);
@@ -3299,12 +3296,20 @@
return 81;
}
+#ifndef USEFULBUF_DISABLE_ALL_FLOAT
static const uint8_t spLabelTypes[] = {
0xA8, 0x01, 0x01, 0x42, 0x78, 0x78, 0x02, 0x64,
0x74, 0x65, 0x78, 0x74, 0x03, 0x80, 0x07, 0xA0,
0x04, 0xC1, 0x18, 0x58, 0x05, 0xF5, 0x06, 0xFB,
0x40, 0x21, 0x8A, 0x3D, 0x70, 0xA3, 0xD7, 0x0A,
0x07};
+#else
+ static const uint8_t spLabelTypes[] = {
+ 0xA7, 0x01, 0x01, 0x42, 0x78, 0x78, 0x02, 0x64,
+ 0x74, 0x65, 0x78, 0x74, 0x03, 0x80, 0x07, 0xA0,
+ 0x04, 0xC1, 0x18, 0x58, 0x05, 0xF5, 0x06};
+#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
+
if(UsefulBuf_CompareWithDiagnostic(EncodedAndSorted,
UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spLabelTypes),
&CompareDiagnostics)) {
diff --git a/test/run_tests.c b/test/run_tests.c
index ed0c26e..30e942e 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -347,6 +347,6 @@
PrintSize("sizeof(QCBORItem)", (uint32_t)sizeof(QCBORItem), pfOutput, pOutCtx);
PrintSize("sizeof(QCBORTagListIn)", (uint32_t)sizeof(QCBORTagListIn), pfOutput, pOutCtx);
PrintSize("sizeof(QCBORTagListOut)", (uint32_t)sizeof(QCBORTagListOut), pfOutput, pOutCtx);
- PrintSize("sizeof(TagSpecification)", (uint32_t)sizeof(TagSpecification), pfOutput, pOutCtx);
+ PrintSize("sizeof(TagSpecification)", (uint32_t)sizeof(QCBOR_Private_TagSpec),pfOutput, pOutCtx);
(*pfOutput)("", pOutCtx, 1);
}