Tagged types tests and bug fixes
diff --git a/QCBOR.xcodeproj/project.pbxproj b/QCBOR.xcodeproj/project.pbxproj
index 5db8c99..53be6ed 100644
--- a/QCBOR.xcodeproj/project.pbxproj
+++ b/QCBOR.xcodeproj/project.pbxproj
@@ -86,7 +86,7 @@
E743D0E124AC516D0017899F /* example.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = example.c; sourceTree = "<group>"; };
E743D0E624AC51C00017899F /* Example */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Example; sourceTree = BUILT_PRODUCTS_DIR; };
E743D0F224AC54600017899F /* example.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = example.h; sourceTree = "<group>"; };
- E743D10824CEDE2D0017899F /* qcbor_spiffy_decode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qcbor_spiffy_decode.h; path = inc/qcbor/qcbor_spiffy_decode.h; sourceTree = "<group>"; };
+ E743D10824CEDE2D0017899F /* qcbor_spiffy_decode.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; name = qcbor_spiffy_decode.h; path = inc/qcbor/qcbor_spiffy_decode.h; sourceTree = "<group>"; tabWidth = 3; };
E74BF411245D6713002CE8E8 /* UsefulBuf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UsefulBuf.h; path = inc/qcbor/UsefulBuf.h; sourceTree = "<group>"; };
E74FA9FE247D2F2C003F8ECE /* Tagging.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Tagging.md; sourceTree = "<group>"; };
E772022723B52C02006E966E /* QCBOR_Disable_Exp_Mantissa */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = QCBOR_Disable_Exp_Mantissa; sourceTree = BUILT_PRODUCTS_DIR; };
diff --git a/inc/qcbor/qcbor_decode.h b/inc/qcbor/qcbor_decode.h
index c3056c9..94cef63 100644
--- a/inc/qcbor/qcbor_decode.h
+++ b/inc/qcbor/qcbor_decode.h
@@ -235,11 +235,13 @@
#define QCBOR_TYPE_DOUBLE 27
/** For @ref QCBOR_DECODE_MODE_MAP_AS_ARRAY decode mode, a map that is
being traversed as an array. See QCBORDecode_Init() */
-#define QCBOR_TYPE_MAP_AS_ARRAY 32
#define QCBOR_TYPE_BREAK 31 // Used internally; never returned
-#define QCBOR_TYPE_UUID 32 // TODO: implement this
+#define QCBOR_TYPE_MAP_AS_ARRAY 32
+
+
+#define QCBOR_TYPE_UUID 41 // TODO: implement this and clean up the rest of this mess
#define QCBOR_TYPE_URI 33 // TODO: implement this
@@ -253,7 +255,7 @@
#define QCBOR_TYPE_BASE64 38
-#define QBCOR_TYPE_WRAPPED_CBOR 39
+#define QBCOR_TYPE_WRAPPED_CBOR 39 // TODO: implement this
#define QBCOR_TYPE_WRAPPED_CBOR_SEQUENCE 40 // TODO: implement this
diff --git a/inc/qcbor/qcbor_spiffy_decode.h b/inc/qcbor/qcbor_spiffy_decode.h
index 732c2d9..086f9b6 100644
--- a/inc/qcbor/qcbor_spiffy_decode.h
+++ b/inc/qcbor/qcbor_spiffy_decode.h
@@ -560,14 +560,14 @@
UsefulBufC *pDateString);
static void QCBORDecode_GetDateStringInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequired,
int64_t nLabel,
+ uint8_t uTagRequired,
UsefulBufC *pDateString);
static void QCBORDecode_GetDateStringInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequired,
- const char *szLabel,
- UsefulBufC *pDateString);
+ const char *szLabel,
+ uint8_t uTagRequired,
+ UsefulBufC *pDateString);
@@ -588,13 +588,13 @@
int64_t *pnTime);
static void QCBORDecode_GetEpochDateInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
int64_t *pnTime);
void QCBORDecode_GetEpochDateInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
int64_t *pnTime);
@@ -637,14 +637,14 @@
bool *pbIsNegative);
void QCBORDecode_GetBignumInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pValue,
bool *pbIsNegative);
-void QCBORDecode_GetBignumInMapSz(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
+void QCBORDecode_GetBignumInMapSZ(QCBORDecodeContext *pCtx,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pValue,
bool *pbIsNegative);
@@ -690,14 +690,14 @@
int64_t *pnExponent);
void QCBORDecode_GetDecimalFractionInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
int64_t *pnMantissa,
int64_t *pnExponent);
void QCBORDecode_GetDecimalFractionInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
int64_t *pnMantissa,
int64_t *pnExponent);
@@ -734,16 +734,16 @@
int64_t *pnExponent);
void QCBORDecode_GetDecimalFractionBigInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBuf MantissaBuffer,
UsefulBufC *pbMantissaIsNegative,
bool *pbIsNegative,
int64_t *pnExponent);
void QCBORDecode_GetDecimalFractionBigInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBuf MantissaBuffer,
UsefulBufC *pMantissa,
bool *pbMantissaIsNegative,
@@ -773,14 +773,14 @@
int64_t *pnExponent);
void QCBORDecode_GetBigFloatInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
int64_t *pnMantissa,
int64_t *pnExponent);
void QCBORDecode_GetBigFloatInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
int64_t *pnMantissa,
int64_t *pnExponent);
@@ -812,16 +812,16 @@
int64_t *pnExponent);
void QCBORDecode_GetBigFloatBigInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBuf MantissaBuffer,
UsefulBufC *pMantissa,
bool *pbMantissaIsNegative,
int64_t *pnExponent);
void QCBORDecode_GetBigFloatBigInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBuf MantissaBuffer,
UsefulBufC *pMantissa,
bool *pbMantissaIsNegative,
@@ -845,13 +845,13 @@
UsefulBufC *pURI);
static void QCBORDecode_GetURIInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pURI);
static void QCBORDecode_GetURIInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char * szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pURI);
@@ -873,13 +873,13 @@
UsefulBufC *pB64Text);
static void QCBORDecode_GetB64InMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pB64Text);
static void QCBORDecode_GetB64InMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pB64Text);
/**
@@ -900,13 +900,13 @@
UsefulBufC *pB64Text);
static void QCBORDecode_GetB64URLInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pB64Text);
static void QCBORDecode_GetB64URLInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pB64Text);
/**
@@ -925,13 +925,13 @@
UsefulBufC *pRegex);
static void QCBORDecode_GetRegexInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pRegex);
static void QCBORDecode_GetRegexInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char * szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pRegex);
@@ -962,15 +962,15 @@
bool *pbIsNot7Bit);
static void QCBORDecode_GetMIMEMessageInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pMessage,
bool *pbIsNot7Bit);
static void QCBORDecode_GetMIMEMessageInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pMessage,
bool *pbIsNot7Bit);
@@ -990,13 +990,13 @@
UsefulBufC *pUUID);
inline static void QCBORDecode_GetBinaryUUIDInMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pUUID);
inline static void QCBORDecode_GetBinaryUUIDInMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pUUID);
@@ -1168,13 +1168,13 @@
UsefulBufC *pBstr);
void QCBORDecode_EnterBstrWrappedFromMapN(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pBstr);
void QCBORDecode_EnterBstrWrappedFromMapSZ(QCBORDecodeContext *pCtx,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pBstr);
@@ -1670,37 +1670,43 @@
static inline void QCBORDecode_GetDateString(QCBORDecodeContext *pMe, uint8_t uTagRequirement, UsefulBufC *pValue)
{
- const TagSpecification TagSpec = {uTagRequirement,
- {QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
- {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
- };
+ const TagSpecification TagSpec =
+ {
+ uTagRequirement,
+ {QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
+ {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
+ };
QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pValue);
}
inline static void QCBORDecode_GetDateStringInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
- int64_t nLabel,
- UsefulBufC *pText)
+ int64_t nLabel,
+ uint8_t uTagRequirement,
+ UsefulBufC *pText)
{
- const TagSpecification TagSpec = {uTagRequirement,
- {QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
- {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
- };
+ const TagSpecification TagSpec =
+ {
+ uTagRequirement,
+ {QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
+ {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
+ };
QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
}
inline static void QCBORDecode_GetDateStringInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pText)
{
- const TagSpecification TagSpec = {uTagRequirement,
- {QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
- {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
- };
+ const TagSpecification TagSpec =
+ {
+ uTagRequirement,
+ {QCBOR_TYPE_DATE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
+ {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
+ };
QCBORDecode_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
}
@@ -1710,32 +1716,35 @@
uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
- const TagSpecification TagSpec = {uTagRequirement,
- {QCBOR_TYPE_URI, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
- {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
- };
+ const TagSpecification TagSpec =
+ {
+ uTagRequirement,
+ {QCBOR_TYPE_URI, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
+ {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
+ };
QCBORDecode_GetTaggedStringInternal(pMe, TagSpec, pUUID);
}
inline static void QCBORDecode_GetURIInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
- const TagSpecification TagSpec = {uTagRequirement,
- {QCBOR_TYPE_URI, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
- {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
- };
+ const TagSpecification TagSpec =
+ {uTagRequirement,
+ {QCBOR_TYPE_URI, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE},
+ {QCBOR_TYPE_TEXT_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
+ };
QCBORDecode_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pUUID);
}
inline static void QCBORDecode_GetURIInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1762,8 +1771,8 @@
inline static void QCBORDecode_GetB64InMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1775,8 +1784,8 @@
}
inline static void QCBORDecode_GetB64InMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1801,8 +1810,8 @@
inline static void QCBORDecode_GetB64URLInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1815,8 +1824,8 @@
inline static void QCBORDecode_GetB64URLInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pB64Text)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1841,8 +1850,8 @@
static inline void QCBORDecode_GetRegexInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pRegex)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1855,8 +1864,8 @@
static inline void QCBORDecode_GetRegexInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char * szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pRegex)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1890,28 +1899,32 @@
static inline void QCBORDecode_GetMIMEMessageInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pMessage,
bool *pbIsNot7Bit)
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
- pMe->uLastError = (uint8_t)QCBORDecode_GetMIMEInternal(uTagRequirement, &Item, pMessage, pbIsNot7Bit);
+ if(pMe->uLastError == QCBOR_SUCCESS) {
+ pMe->uLastError = (uint8_t)QCBORDecode_GetMIMEInternal(uTagRequirement, &Item, pMessage, pbIsNot7Bit);
+ }
}
static inline void QCBORDecode_GetMIMEMessageInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pMessage,
bool *pbIsNot7Bit)
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
- pMe->uLastError = (uint8_t)QCBORDecode_GetMIMEInternal(uTagRequirement, &Item, pMessage, pbIsNot7Bit);
+ if(pMe->uLastError == QCBOR_SUCCESS) {
+ pMe->uLastError = (uint8_t)QCBORDecode_GetMIMEInternal(uTagRequirement, &Item, pMessage, pbIsNot7Bit);
+ }
}
@@ -1930,8 +1943,8 @@
inline static void QCBORDecode_GetBinaryUUIDInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1943,8 +1956,8 @@
}
inline static void QCBORDecode_GetBinaryUUIDInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pUUID)
{
const TagSpecification TagSpec = {uTagRequirement,
@@ -1957,8 +1970,8 @@
inline static void QCBORDecode_GetEpochDateInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
int64_t *puTime)
{
const TagSpecification TagSpec = {uTagRequirement,
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 1594bb0..17eefbe 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -1765,7 +1765,7 @@
{
if(pDecodedItem->uDataType == QCBOR_TYPE_TEXT_STRING) {
pDecodedItem->uDataType = QCBOR_TYPE_MIME;
- } else if(pDecodedItem->uDataType != QCBOR_TYPE_BYTE_STRING) {
+ } else if(pDecodedItem->uDataType == QCBOR_TYPE_BYTE_STRING) {
pDecodedItem->uDataType = QCBOR_TYPE_BINARY_MIME;
} else {
return QCBOR_ERR_BAD_OPT_TAG;
@@ -3039,8 +3039,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_EnterBstrWrappedFromMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pBstr)
{
QCBORItem Item;
@@ -3054,8 +3054,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_EnterBstrWrappedFromMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBufC *pBstr)
{
QCBORItem Item;
@@ -3189,15 +3189,17 @@
-static QCBORError ConvertBigNum(uint8_t uTagRequirement,
+static QCBORError ProcessBigNum(uint8_t uTagRequirement,
const QCBORItem *pItem,
- UsefulBufC *pValue,
- bool *pbIsNegative)
+ UsefulBufC *pValue,
+ bool *pbIsNegative)
{
- const TagSpecification TagSpec = {uTagRequirement,
- {QCBOR_TYPE_POSBIGNUM, QCBOR_TYPE_NEGBIGNUM, QCBOR_TYPE_NONE},
- {QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
- };
+ const TagSpecification TagSpec =
+ {
+ uTagRequirement,
+ {QCBOR_TYPE_POSBIGNUM, QCBOR_TYPE_NEGBIGNUM, QCBOR_TYPE_NONE},
+ {QCBOR_TYPE_BYTE_STRING, QCBOR_TYPE_NONE, QCBOR_TYPE_NONE}
+ };
QCBORError uErr = CheckTagRequirement(TagSpec, pItem->uDataType);
if(uErr != QCBOR_SUCCESS) {
@@ -3233,29 +3235,45 @@
return;
}
- pMe->uLastError = (uint8_t)ConvertBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
+ pMe->uLastError = (uint8_t)ProcessBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
}
+
/*
Public function, see header qcbor/qcbor_decode.h
*/
-void QCBORDecode_GetBignumInMapN(QCBORDecodeContext *pMe, uint8_t uTagRequirement, int64_t nLabel, UsefulBufC *pValue, bool *pbIsNegative)
+void QCBORDecode_GetBignumInMapN(QCBORDecodeContext *pMe,
+ int64_t nLabel,
+ uint8_t uTagRequirement,
+ UsefulBufC *pValue,
+ bool *pbIsNegative)
{
QCBORItem Item;
QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
+ if(pMe->uLastError != QCBOR_SUCCESS) {
+ return;
+ }
- pMe->uLastError = (uint8_t)ConvertBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
+ pMe->uLastError = (uint8_t)ProcessBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
}
+
/*
Public function, see header qcbor/qcbor_decode.h
*/
-void QCBORDecode_GetBignumInMapSZ(QCBORDecodeContext *pMe, uint8_t uTagRequirement, const char *szLabel, UsefulBufC *pValue, bool *pbIsNegative)
+void QCBORDecode_GetBignumInMapSZ(QCBORDecodeContext *pMe,
+ const char *szLabel,
+ uint8_t uTagRequirement,
+ UsefulBufC *pValue,
+ bool *pbIsNegative)
{
QCBORItem Item;
QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
+ if(pMe->uLastError != QCBOR_SUCCESS) {
+ return;
+ }
- pMe->uLastError = (uint8_t)ConvertBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
+ pMe->uLastError = (uint8_t)ProcessBigNum(uTagRequirement, &Item, pValue, pbIsNegative);
}
@@ -3274,13 +3292,13 @@
QCBORError uReturn;
- if(CheckTagRequirement(TagSpecText, pItem->uDataType)) {
+ if(CheckTagRequirement(TagSpecText, pItem->uDataType) == QCBOR_SUCCESS) {
*pMessage = pItem->val.string;
if(pbIsNot7Bit != NULL) {
*pbIsNot7Bit = false;
}
uReturn = QCBOR_SUCCESS;
- } else if(CheckTagRequirement(TagSpecBinary, pItem->uDataType)) {
+ } else if(CheckTagRequirement(TagSpecBinary, pItem->uDataType) == QCBOR_SUCCESS) {
*pMessage = pItem->val.string;
if(pbIsNot7Bit != NULL) {
*pbIsNot7Bit = true;
@@ -4595,8 +4613,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_GetDecimalFractionInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
int64_t *pnMantissa,
int64_t *pnExponent)
{
@@ -4622,8 +4640,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_GetDecimalFractionInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
int64_t *pnMantissa,
int64_t *pnExponent)
{
@@ -4681,8 +4699,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_GetDecimalFractionBigInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBuf BufferForMantissa,
UsefulBufC *pMantissa,
bool *pbIsNegative,
@@ -4713,8 +4731,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_GetDecimalFractionBigInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBuf BufferForMantissa,
UsefulBufC *pMantissa,
bool *pbIsNegative,
@@ -4774,8 +4792,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_GetBigFloatInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
int64_t *pnMantissa,
int64_t *pnExponent)
{
@@ -4804,8 +4822,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_GetBigFloatInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
int64_t *pnMantissa,
int64_t *pnExponent)
{
@@ -4866,8 +4884,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_GetBigFloatBigInMapN(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
int64_t nLabel,
+ uint8_t uTagRequirement,
UsefulBuf BufferForMantissa,
UsefulBufC *pMantissa,
bool *pbIsNegative,
@@ -4898,8 +4916,8 @@
Public function, see header qcbor/qcbor_decode.h file
*/
void QCBORDecode_GetBigFloatBigInMapSZ(QCBORDecodeContext *pMe,
- uint8_t uTagRequirement,
const char *szLabel,
+ uint8_t uTagRequirement,
UsefulBuf BufferForMantissa,
UsefulBufC *pMantissa,
bool *pbIsNegative,
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index dc4c949..8e73d88 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -5205,13 +5205,62 @@
static const uint8_t spTaggedTypes[] = {
- 0xa2,
- 0x00, 0xc0, 0x61, 0x50,
- 0x01, 0x61, 0x50,
+ 0xb2,
+ 0x00,
+ 0xc0, 0x74, 0x32, 0x30, 0x30, 0x33, 0x2D, 0x31, 0x32, 0x2D, 0x31, 0x33, 0x54, 0x31, 0x38, 0x3A, 0x33, 0x30, 0x3A, 0x30, 0x32, 0x5A,
+ 0x01,
+ 0x74, 0x32, 0x30, 0x30, 0x33, 0x2D, 0x31, 0x32, 0x2D, 0x31, 0x33, 0x54, 0x31, 0x38, 0x3A, 0x33, 0x30, 0x3A, 0x30, 0x32, 0x5A,
+ 10,
+ 0xC2, 0x4A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
+ 11,
+ 0xC3, 0x4A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
+
+ 20,
+ 0xd8, 0x20, 0x6f, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x63, 0x62, 0x6F, 0x72, 0x2E, 0x6D, 0x65, 0x2F,
+ 21,
+ 0x6f, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x63, 0x62, 0x6F, 0x72, 0x2E, 0x6D, 0x65, 0x2F,
+
+ 0x18, 0x1e,
+ 0xd8, 0x22, 0x6c, 0x63, 0x47, 0x78, 0x6C, 0x59, 0x58, 0x4E, 0x31, 0x63, 0x6D, 0x55, 0x75,
+
+ 0x18, 0x1f,
+ 0x6c, 0x63, 0x47, 0x78, 0x6C, 0x59, 0x58, 0x4E, 0x31, 0x63, 0x6D, 0x55, 0x75,
+
+ 0x18, 0x28,
+ 0xd8, 0x21, 0x6c, 0x63, 0x47, 0x78, 0x6C, 0x59, 0x58, 0x4E, 0x31, 0x63, 0x6D, 0x55, 0x75,
+
+ 0x18, 0x29,
+ 0x6c, 0x63, 0x47, 0x78, 0x6C, 0x59, 0x58, 0x4E, 0x31, 0x63, 0x6D, 0x55, 0x75,
+
+ 0x18, 0x32,
+ 0xd8, 0x23, 0x68, 0x31, 0x30, 0x30, 0x5C, 0x73, 0x2A, 0x6D, 0x6B,
+
+ 0x18, 0x33,
+ 0x68, 0x31, 0x30, 0x30, 0x5C, 0x73, 0x2A, 0x6D, 0x6B,
+
+ // MIME
+ 0x18, 0x3c,
+ 0xd8, 0x24, 0x72, 0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E, 0x30, 0x0A,
+
+ 0x18, 0x3d,
+ 0x72, 0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E, 0x30, 0x0A,
+
+ 0x18, 0x3e,
+ 0xd9, 0x01, 0x01, 0x52, 0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E, 0x30, 0x0A,
+
+ 0x18, 0x3f,
+ 0x52, 0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E, 0x30, 0x0A,
+
+ // UUID
+ 0x18, 0x46,
+ 0xd8, 0x25, 0x50, 0x53, 0x4D, 0x41, 0x52, 0x54, 0x43, 0x53, 0x4C, 0x54, 0x54, 0x43, 0x46, 0x49, 0x43, 0x41, 0x32,
+
+ 0x18, 0x47,
+ 0x50, 0x53, 0x4D, 0x41, 0x52, 0x54, 0x43, 0x53, 0x4C, 0x54, 0x54, 0x43, 0x46, 0x49, 0x43, 0x41, 0x32
};
int32_t DecodeTaggedTypeTests()
@@ -5222,44 +5271,171 @@
QCBORDecode_Init(&DC, UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spTaggedTypes), 0);
UsefulBufC String;
- //bool bNeg;
+ bool bNeg;
QCBORDecode_EnterMap(&DC);
- QCBORDecode_GetDateStringInMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 0, &String);
- QCBORDecode_GetDateStringInMapN(&DC, QCBOR_TAG_REQUIREMENT_OPTIONAL_TAG, 0, &String);
+ QCBORDecode_GetDateStringInMapN(&DC, 0, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ QCBORDecode_GetDateStringInMapN(&DC, 0, QCBOR_TAG_REQUIREMENT_OPTIONAL_TAG, &String);
if(QCBORDecode_GetError(&DC) != QCBOR_SUCCESS) {
return 1;
}
- QCBORDecode_GetDateStringInMapN(&DC, QCBOR_TAG_REQUIREMENT_NO_TAG, 0, &String);
+ QCBORDecode_GetDateStringInMapN(&DC, 0, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_UNEXPECTED_TYPE) {
return 2;
}
- QCBORDecode_GetDateStringInMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 1, &String);
+ QCBORDecode_GetDateStringInMapN(&DC, 1, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_UNEXPECTED_TYPE) {
return 3;
}
- QCBORDecode_GetDateStringInMapN(&DC, QCBOR_TAG_REQUIREMENT_OPTIONAL_TAG, 1, &String);
- QCBORDecode_GetDateStringInMapN(&DC, QCBOR_TAG_REQUIREMENT_NO_TAG, 1, &String);
+ QCBORDecode_GetDateStringInMapN(&DC, 1, QCBOR_TAG_REQUIREMENT_OPTIONAL_TAG, &String);
+ QCBORDecode_GetDateStringInMapN(&DC, 1, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
return 4;
}
+ QCBORDecode_GetDateStringInMapSZ(&DC, "xxx", QCBOR_TAG_REQUIREMENT_OPTIONAL_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 5;
+ }
- /*
- QCBORDecode_GetBignumInMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 10, &String, &bNeg);
+ QCBORDecode_GetBignumInMapN(&DC, 10, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String, &bNeg);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS ||
+ bNeg != false) {
+ return 10;
+ }
+ QCBORDecode_GetBignumInMapN(&DC, 11, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String, &bNeg);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS ||
+ bNeg != true) {
+ return 11;
+ }
+ QCBORDecode_GetBignumInMapN(&DC, 11, QCBOR_TAG_REQUIREMENT_NO_TAG, &String, &bNeg);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_UNEXPECTED_TYPE) {
+ return 12;
+ }
+ QCBORDecode_GetBignumInMapN(&DC, 14, QCBOR_TAG_REQUIREMENT_NO_TAG, &String, &bNeg);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 13;
+ }
+ QCBORDecode_GetBignumInMapSZ(&DC, "xxx", QCBOR_TAG_REQUIREMENT_NO_TAG, &String, &bNeg);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 14;
+ }
- QCBORDecode_GetURIInMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 20, &String);
+ QCBORDecode_GetURIInMapN(&DC, 20, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 20;
+ }
+ QCBORDecode_GetURIInMapN(&DC, 21, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 21;
+ }
+ QCBORDecode_GetURIInMapN(&DC, 22, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 22;
+ }
+ QCBORDecode_GetURIInMapSZ(&DC, "xxx", QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 23;
+ }
- QCBORDecode_GetB64InMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 30, &String);
+ QCBORDecode_GetB64InMapN(&DC, 30, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 30;
+ }
+ QCBORDecode_GetB64InMapN(&DC, 31, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 31;
+ }
+ QCBORDecode_GetB64InMapN(&DC, 32, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 32;
+ }
+ QCBORDecode_GetB64InMapSZ(&DC, "xxx", QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 33;
+ }
- QCBORDecode_GetB64URLInMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 40, &String);
+ QCBORDecode_GetB64URLInMapN(&DC, 40, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 40;
+ }
+ QCBORDecode_GetB64URLInMapN(&DC, 41, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 41;
+ }
+ QCBORDecode_GetB64URLInMapN(&DC, 42, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 42;
+ }
+ QCBORDecode_GetB64URLInMapSZ(&DC, "xxx", QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 43;
+ }
- QCBORDecode_GetRegexInMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 50, &String);
+ QCBORDecode_GetRegexInMapN(&DC, 50, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 50;
+ }
+ QCBORDecode_GetRegexInMapN(&DC, 51, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 51;
+ }
+ QCBORDecode_GetRegexInMapN(&DC, 52, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 52;
+ }
+ QCBORDecode_GetRegexInMapSZ(&DC, "xxx", QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 53;
+ }
- QCBORDecode_GetMIMEMessageInMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 60, &String, &bNeg);
+ // MIME
+ bool bIsNot7Bit;
+ QCBORDecode_GetMIMEMessageInMapN(&DC, 60, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String, &bIsNot7Bit);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS ||
+ bIsNot7Bit == true) {
+ return 60;
+ }
+ QCBORDecode_GetMIMEMessageInMapN(&DC, 61, QCBOR_TAG_REQUIREMENT_NO_TAG, &String, &bIsNot7Bit);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS ||
+ bIsNot7Bit == true) {
+ return 61;
+ }
+ QCBORDecode_GetMIMEMessageInMapN(&DC, 62, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String, &bIsNot7Bit);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS ||
+ bIsNot7Bit == false) {
+ return 62;
+ }
+ QCBORDecode_GetMIMEMessageInMapN(&DC, 63, QCBOR_TAG_REQUIREMENT_NO_TAG, &String, &bIsNot7Bit);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS ||
+ bIsNot7Bit == false) {
+ return 63;
+ }
+ QCBORDecode_GetMIMEMessageInMapN(&DC, 64, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String, &bNeg);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 64;
+ }
+ QCBORDecode_GetMIMEMessageInMapSZ(&DC, "zzz", QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String, &bNeg);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 65;
+ }
- QCBORDecode_GetBinaryUUIDInMapN(&DC, QCBOR_TAG_REQUIREMENT_MATCH_TAG, 70, &String);
+ QCBORDecode_GetBinaryUUIDInMapN(&DC, 70, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 70;
+ }
+ QCBORDecode_GetBinaryUUIDInMapN(&DC, 71, QCBOR_TAG_REQUIREMENT_NO_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_SUCCESS) {
+ return 71;
+ }
+ QCBORDecode_GetBinaryUUIDInMapN(&DC, 72, QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 72;
+ }
+ QCBORDecode_GetBinaryUUIDInMapSZ(&DC, "xxx", QCBOR_TAG_REQUIREMENT_MATCH_TAG, &String);
+ if(QCBORDecode_GetAndResetError(&DC) != QCBOR_ERR_NOT_FOUND) {
+ return 73;
+ }
- */
QCBORDecode_ExitMap(&DC);
uErr = QCBORDecode_Finish(&DC);