Skip to content

Commit

Permalink
Merge latest stuff from master (what is to be v 1.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Lundblade committed Nov 4, 2024
2 parents 6876933 + 88ba566 commit 033574f
Show file tree
Hide file tree
Showing 12 changed files with 793 additions and 336 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ set(HEADERS
)
set_target_properties(
qcbor PROPERTIES
PUBLIC_HEADER "${HEADERS}"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
PUBLIC_HEADER "${HEADERS}"
)
include(GNUInstallDirs)
install(
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ implementations as seen in the following example.
/* Encode */
QCBOREncode_Init(&EncodeCtx, Buffer);
QCBOREncode_OpenMap(&EncodeCtx);
QCBOREncode_AddTextToMap(&EncodeCtx, "Manufacturer", pE->Manufacturer);
QCBOREncode_AddInt64ToMap(&EncodeCtx, "Displacement", pE->uDisplacement);
QCBOREncode_AddInt64ToMap(&EncodeCtx, "Horsepower", pE->uHorsePower);
QCBOREncode_AddTextToMapSZ(&EncodeCtx, "Manufacturer", pE->Manufacturer);
QCBOREncode_AddInt64ToMapSZ(&EncodeCtx, "Displacement", pE->uDisplacement);
QCBOREncode_AddInt64ToMapSZ(&EncodeCtx, "Horsepower", pE->uHorsePower);
QCBOREncode_CloseMap(&EncodeCtx);
uErr = QCBOREncode_Finish(&EncodeCtx, &EncodedEngine);

Expand Down
16 changes: 8 additions & 8 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static bool EngineCompare(const CarEngine *pE1, const CarEngine *pE2)
* @return The pointer and length of the encoded CBOR or
* @ref NULLUsefulBufC on error.
*
* This encodes the input structure \c pEngine as a CBOR map of
* This encodes the input structure @c pEngine as a CBOR map of
* label-value pairs. An array of float is one of the items in the
* map.
*
Expand Down Expand Up @@ -162,22 +162,22 @@ UsefulBufC EncodeEngine(const CarEngine *pEngine, UsefulBuf Buffer)
/* Proceed to output all the items, letting the internal error
* tracking do its work */
QCBOREncode_OpenMap(&EncodeCtx);
QCBOREncode_AddTextToMap(&EncodeCtx, "Manufacturer", pEngine->Manufacturer);
QCBOREncode_AddInt64ToMap(&EncodeCtx, "NumCylinders", pEngine->uNumCylinders);
QCBOREncode_AddInt64ToMap(&EncodeCtx, "Displacement", pEngine->uDisplacement);
QCBOREncode_AddInt64ToMap(&EncodeCtx, "Horsepower", pEngine->uHorsePower);
QCBOREncode_AddTextToMapSZ(&EncodeCtx, "Manufacturer", pEngine->Manufacturer);
QCBOREncode_AddInt64ToMapSZ(&EncodeCtx, "NumCylinders", pEngine->uNumCylinders);
QCBOREncode_AddInt64ToMapSZ(&EncodeCtx, "Displacement", pEngine->uDisplacement);
QCBOREncode_AddInt64ToMapSZ(&EncodeCtx, "Horsepower", pEngine->uHorsePower);
#ifndef USEFULBUF_DISABLE_ALL_FLOAT
QCBOREncode_AddDoubleToMap(&EncodeCtx, "DesignedCompression", pEngine->dDesignedCompresion);
QCBOREncode_AddDoubleToMapSZ(&EncodeCtx, "DesignedCompression", pEngine->dDesignedCompresion);
#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
QCBOREncode_OpenArrayInMap(&EncodeCtx, "Cylinders");
QCBOREncode_OpenArrayInMapSZ(&EncodeCtx, "Cylinders");
#ifndef USEFULBUF_DISABLE_ALL_FLOAT
for(int64_t i = 0 ; i < pEngine->uNumCylinders; i++) {
QCBOREncode_AddDouble(&EncodeCtx,
pEngine->cylinders[i].dMeasuredCompression);
}
#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
QCBOREncode_CloseArray(&EncodeCtx);
QCBOREncode_AddBoolToMap(&EncodeCtx, "Turbo", pEngine->bTurboCharged);
QCBOREncode_AddBoolToMapSZ(&EncodeCtx, "Turbo", pEngine->bTurboCharged);
QCBOREncode_CloseMap(&EncodeCtx);

/* Get the pointer and length of the encoded output. If there was
Expand Down
4 changes: 2 additions & 2 deletions inc/qcbor/UsefulBuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1361,8 +1361,8 @@ UsefulOutBuf_GetOutPlace(UsefulOutBuf *pUOutBuf);
* @param[in] uAmount The amount to advance.
*
* This advances the position in the output buffer
* by \c uAmount. This assumes that the
* caller has written \c uAmount to the pointer obtained
* by @c uAmount. This assumes that the
* caller has written @c uAmount to the pointer obtained
* with UsefulOutBuf_GetOutPlace().
*
* Warning: this bypasses the buffer safety provided by
Expand Down
8 changes: 4 additions & 4 deletions inc/qcbor/qcbor_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,17 @@ extern "C" {
#define CBOR_TAG_ENC_AS_B16 23
/** See QCBORDecode_EnterBstrWrapped()). */
#define CBOR_TAG_CBOR 24
/** See QCBOREncode_AddURI(). */
/** See QCBOREncode_AddTURI(). */
#define CBOR_TAG_URI 32
/** See QCBOREncode_AddB64URLText(). */
/** See QCBOREncode_AddTB64URLText(). */
#define CBOR_TAG_B64URL 33
/** See QCBOREncode_AddB64Text(). */
#define CBOR_TAG_B64 34
/** See QCBOREncode_AddRegex(). */
/** See QCBOREncode_AddTRegex(). */
#define CBOR_TAG_REGEX 35
/** See QCBOREncode_AddMIMEData(). */
#define CBOR_TAG_MIME 36
/** See QCBOREncode_AddBinaryUUID(). */
/** See QCBOREncode_AddTBinaryUUID(). */
#define CBOR_TAG_BIN_UUID 37
/** The data is a CBOR Web Token per [RFC 8392]
* (https://www.rfc-editor.org/rfc/rfc8392.html). No API is provided for this
Expand Down
38 changes: 25 additions & 13 deletions inc/qcbor/qcbor_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ typedef struct _QCBORItem {
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
QCBORExpAndMantissa expAndMantissa;
#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
uint64_t uTagNumber;
uint64_t uTagNumber; /* Used internally during decoding */

/* For use by user-defined tag content handlers */
uint8_t userDefined[24];
Expand Down Expand Up @@ -951,8 +951,8 @@ QCBORDecode_SetUpAllocator(QCBORDecodeContext *pCtx,
*
* See [Decode Error Overview](#Decode-Errors-Overview).
*
* If a decoding error occurs or previously occured, \c uDataType and
* \c uLabelType will be set to @ref QCBOR_TYPE_NONE. If there is no
* If a decoding error occurs or previously occured, @c uDataType and
* @c uLabelType will be set to @ref QCBOR_TYPE_NONE. If there is no
* need to know the specific error, it is sufficient to check for @ref
* QCBOR_TYPE_NONE.
*
Expand Down Expand Up @@ -1468,11 +1468,11 @@ QCBORDecode_IsUnrecoverableError(QCBORError uErr);
* and propagate up.
*
* When the error condition is set, QCBORDecode_VGetNext() will always
* return an item with data and label type as \ref QCBOR_TYPE_NONE.
* return an item with data and label type as @ref QCBOR_TYPE_NONE.
*
* The main intent of this is to set a user-defined error code in the
* range of \ref QCBOR_ERR_FIRST_USER_DEFINED to
* \ref QCBOR_ERR_LAST_USER_DEFINED, but it is OK to set QCBOR-defined
* range of @ref QCBOR_ERR_FIRST_USER_DEFINED to
* @ref QCBOR_ERR_LAST_USER_DEFINED, but it is OK to set QCBOR-defined
* error codes too.
*/
static void
Expand Down Expand Up @@ -1697,10 +1697,13 @@ QCBOR_Int64ToUInt64(int64_t src, uint64_t *dest)



/* ------------------------------------------------------------------------
* Deprecated functions retained for backwards compatibility. Their use is
* not recommended.
* ---- */

/* ========================================================================= *
* BEGINNING OF DEPRECATED FUNCTIONS *
* *
* There is no plan to remove these in future versions. *
* They just have been replaced by something better. *
* ========================================================================= */

/**
* TODO: Initialize the CBOR decoder context with QCBOR v1 compatibility (deprecated).
Expand Down Expand Up @@ -1764,11 +1767,16 @@ uint64_t
QCBORDecode_GetNthTagOfLast(const QCBORDecodeContext *pCtx, uint32_t uIndex);

#endif /* ! QCBOR_DISABLE_TAGS */
/* ========================================================================= *
* END OF DEPRECATED FUNCTIONS *
* ========================================================================= */



/* ------------------------------------------------------------------------
* Inline implementations of public functions defined above.
* ---- */

/* ========================================================================= *
* BEGINNING OF PRIVATE INLINE IMPLEMENTATION *
* ========================================================================= */

static inline uint32_t
QCBORDecode_Tell(QCBORDecodeContext *pMe)
Expand Down Expand Up @@ -1830,6 +1838,10 @@ QCBORDecode_SetError(QCBORDecodeContext *pMe, QCBORError uError)
pMe->uLastError = (uint8_t)uError;
}

/* ======================================================================== *
* END OF PRIVATE INLINE IMPLEMENTATION *
* ======================================================================== */


/* A few cross checks on size constants and special value lengths */
#if QCBOR_MAP_OFFSET_CACHE_INVALID < QCBOR_MAX_DECODE_INPUT_SIZE
Expand Down
Loading

0 comments on commit 033574f

Please sign in to comment.