Cleanup, TODO:'s ....
diff --git a/cmd_line_main.c b/cmd_line_main.c
index 9e4a819..ef59e43 100644
--- a/cmd_line_main.c
+++ b/cmd_line_main.c
@@ -32,7 +32,7 @@
{
(void)argc; // Avoid unused parameter error
- RunQCborExample(); // TODO: organize this better
+ RunQCborExample();
// This call prints out sizes of data structures to remind us
diff --git a/example.c b/example.c
index 39e6d55..f855194 100644
--- a/example.c
+++ b/example.c
@@ -256,7 +256,7 @@
QCBORDecode_Init(&DecodeCtx, EncodedEngine, QCBOR_DECODE_MODE_NORMAL);
QCBORDecode_EnterMap(&DecodeCtx);
- QCBORDecode_GetTextInMapSZ(&DecodeCtx, "Manufacturer", &(pE->Manufacturer));
+ QCBORDecode_GetTextStringInMapSZ(&DecodeCtx, "Manufacturer", &(pE->Manufacturer));
QCBORDecode_GetInt64InMapSZ(&DecodeCtx, "Displacement", &(pE->uDisplacement));
QCBORDecode_GetInt64InMapSZ(&DecodeCtx, "Horsepower", &(pE->uHorsePower));
QCBORDecode_GetDoubleInMapSZ(&DecodeCtx, "DesignedCompression", &(pE->dDesignedCompresion));
@@ -493,7 +493,7 @@
{
QCBORDecodeContext DecodeCtx;
- QCBORDecode_Init(&DecodeCtx, EncodedEngine, 0);// TODO: fill in mode;
+ QCBORDecode_Init(&DecodeCtx, EncodedEngine, QCBOR_DECODE_MODE_NORMAL);
QCBORItem Item;
QCBORError uErr;
diff --git a/inc/qcbor/qcbor_common.h b/inc/qcbor/qcbor_common.h
index 04d9d04..aaa46a1 100644
--- a/inc/qcbor/qcbor_common.h
+++ b/inc/qcbor/qcbor_common.h
@@ -120,12 +120,12 @@
mantissa and base-2 scaling factor. See QCBOREncode_AddBigFloat()
and @ref expAndMantissa. */
#define CBOR_TAG_BIGFLOAT 5
-/** Tag for COSE format encryption with no recipient
+/** Not Decoded by QCBOR. Tag for COSE format encryption with no recipient
identification. See [RFC 8152, COSE]
(https://tools.ietf.org/html/rfc8152). No API is provided for this
tag. */
#define CBOR_TAG_COSE_ENCRYPTO 16
-/** Tag for COSE format MAC'd data with no recipient
+/** Not Decoded by QCBOR. Tag for COSE format MAC'd data with no recipient
identification. See [RFC 8152, COSE]
(https://tools.ietf.org/html/rfc8152). No API is provided for this
tag.*/
@@ -175,20 +175,19 @@
/** Tag for COSE format encryption. See [RFC 8152, COSE]
(https://tools.ietf.org/html/rfc8152). No API is provided for this
tag. */
-
#define CBOR_TAG_CBOR_SEQUENCE 63
#define CBOR_TAG_ENCRYPT 96
-/** Tag for COSE format MAC. See [RFC 8152, COSE]
+/** Not Decoded by QCBOR. Tag for COSE format MAC. See [RFC 8152, COSE]
(https://tools.ietf.org/html/rfc8152). No API is provided for this
tag. */
#define CBOR_TAG_MAC 97
-/** Tag for COSE format signed data. See [RFC 8152, COSE]
+/** Not Decoded by QCBOR. Tag for COSE format signed data. See [RFC 8152, COSE]
(https://tools.ietf.org/html/rfc8152). No API is provided for this
tag. */
#define CBOR_TAG_SIGN 98
-/** World geographic coordinates. See ISO 6709, [RFC 5870]
+/** Not Decoded by QCBOR. World geographic coordinates. See ISO 6709, [RFC 5870]
(https://tools.ietf.org/html/rfc5870) and WGS-84. No API is
provided for this tag. */
#define CBOR_TAG_GEO_COORD 103
diff --git a/inc/qcbor/qcbor_decode.h b/inc/qcbor/qcbor_decode.h
index be6697a..6982e54 100644
--- a/inc/qcbor/qcbor_decode.h
+++ b/inc/qcbor/qcbor_decode.h
@@ -304,7 +304,7 @@
QCBOR_TYPE_XXXX */
uint8_t uDataType;
/** How deep the nesting from arrays and maps is. 0 is the top
- level with no arrays or maps entered. TODO: udpate this comment*/
+ level with no arrays or maps entered. */
uint8_t uNestingLevel;
/** Tells what element of the label union to use. */
uint8_t uLabelType;
@@ -313,9 +313,9 @@
uint8_t uDataAlloc;
/** Like @c uDataAlloc, but for label. */
uint8_t uLabelAlloc;
- /** If less than @c uNestingLevel, this item was the last one
- in an arry or map and closed out at least
- one nesting level */
+ /** The nesting level of the next item after this one. If less
+ than @c uNestingLevel, this item was the last one in an arry or
+ map and closed out at least one nesting level */
uint8_t uNextNestLevel;
/** The union holding the item's value. Select union member based
@@ -829,37 +829,23 @@
map or array has been encountered. This works the same for both
definite and indefinite-length arrays.
- TODO: revise this documentation on tags. It is wrong.
- This decoder support CBOR type 6 tagging. The decoding of particular
- given tag value may be supported in one of three different ways.
+ QCBOR will automatically decode all the tags defined in RFC 7049
+ plus a few more. They will show up in a QCBORItem as QCBOR types
+ like QCBOR_TYPE_POS_BIGNUM.
- First, some common tags are fully and transparently supported by
- automatically decoding them and returning them in a @ref QCBORItem.
- These tags have a @c QCBOR_TYPE_XXX associated with them and manifest
- pretty much the same as a standard CBOR type. @ref
- QCBOR_TYPE_DATE_EPOCH and the @c epochDate member of @ref QCBORItem
- is an example.
+ Most tags with a CBOR_TAG_XXX define in qcbor_common.h like @ref
+ CBOR_TAG_DATE_STRING are automaticlly decoded by QCBOR. Those that
+ are defined but not decoded are so noted.
- Second are tags that are automatically recognized, but not decoded.
- These are tags that have a @c \#define of the form @c CBOR_TAG_XXX.
- These are recorded in the @c uTagBits member of @ref QCBORItem. There
- is an internal table that maps each bit to a particular tag value
- allowing up to 64 tags on an individual item to be reported (it is
- rare to have more than one or two). To find out if a particular tag
- value is set call QCBORDecode_IsTagged() on the @ref QCBORItem. See
- also QCBORDecode_GetNextWithTags().
+ Tags that are not decoded by QCBOR will be identified and recorded in
+ a QCBORItem. Use QCBORDecode_GetNthTag() to get them. Only @ref
+ QCBOR_MAX_TAGS_PER_ITEM tags are recorded per item and an error is
+ returned if there are more than that.
- Third are tags that are not automatically recognized, because they
- are proprietary, custom or more recently registered with [IANA]
- (https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml). The
- internal mapping table has to be configured to recognize these. Call
- QCBORDecode_SetCallerConfiguredTagList() to do that. Then
- QCBORDecode_IsTagged() will work with them.
-
- The actual decoding of tags supported in the second and third way
- must be handled by the caller. Often this is simply verifying that
- the expected tag is present on a map, byte string or such. In other
- cases, there might a complicated map structure to decode.
+ Previous versions of QCBOR handled tags in a more complex way using
+ QCBORDecode_SetCallerConfiguredTagList() and
+ QCBORDecode_GetNextWithTags(). This is largely compatible, but
+ imposes the limit of @ref QCBOR_MAX_TAGS_PER_ITEM tags per item
See @ref Tags-Overview for a description of how to go about creating
custom tags.
diff --git a/inc/qcbor/qcbor_private.h b/inc/qcbor/qcbor_private.h
index 3146a60..a00f54f 100644
--- a/inc/qcbor/qcbor_private.h
+++ b/inc/qcbor/qcbor_private.h
@@ -180,7 +180,7 @@
#define QCBOR_COUNT_INDICATES_INDEFINITE_LENGTH UINT16_MAX
#define QCBOR_COUNT_INDICATES_ZERO_LENGTH UINT16_MAX-1
uint16_t uCountTotal;
- uint16_t uCountCursor; // TODO: review all uses of this
+ uint16_t uCountCursor;
#define QCBOR_NON_BOUNDED_OFFSET UINT32_MAX
uint32_t uStartOffset;
} ma; /* for maps and arrays */
diff --git a/inc/qcbor/qcbor_spiffy_decode.h b/inc/qcbor/qcbor_spiffy_decode.h
index 0e9178a..a37baf7 100644
--- a/inc/qcbor/qcbor_spiffy_decode.h
+++ b/inc/qcbor/qcbor_spiffy_decode.h
@@ -558,13 +558,13 @@
If the CBOR tem to decode is not a byte string, the @ref
QCBOR_ERR_UNEXPECTED_TYPE error is set.
*/
-static void QCBORDecode_GetBytes(QCBORDecodeContext *pCtx, UsefulBufC *pBytes);
+static void QCBORDecode_GetByteString(QCBORDecodeContext *pCtx, UsefulBufC *pBytes);
-static void QCBORDecode_GetBytesInMapN(QCBORDecodeContext *pCtx,
+static void QCBORDecode_GetByteStringInMapN(QCBORDecodeContext *pCtx,
int64_t nLabel,
UsefulBufC *pBytes);
-static void QCBORDecode_GetBytesInMapSZ(QCBORDecodeContext *pCtx,
+static void QCBORDecode_GetByteStringInMapSZ(QCBORDecodeContext *pCtx,
const char *szLabel,
UsefulBufC *pBytes);
@@ -581,13 +581,13 @@
to decode is not a text string, the @ref QCBOR_ERR_UNEXPECTED_TYPE
error is set.
*/
-static void QCBORDecode_GetText(QCBORDecodeContext *pCtx, UsefulBufC *pText);
+static void QCBORDecode_GetTextString(QCBORDecodeContext *pCtx, UsefulBufC *pText);
-static void QCBORDecode_GetTextInMapN(QCBORDecodeContext *pCtx,
+static void QCBORDecode_GetTextStringInMapN(QCBORDecodeContext *pCtx,
int64_t nLabel,
UsefulBufC *pText);
-static void QCBORDecode_GetTextInMapSZ(QCBORDecodeContext *pCtx,
+static void QCBORDecode_GetTextStringInMapSZ(QCBORDecodeContext *pCtx,
const char *szLabel,
UsefulBufC *pText);
@@ -1498,7 +1498,8 @@
processing error that is not a CBOR error. The specific details of
the protocol processing error can be returned the call back context.
*/
-typedef QCBORError (*QCBORItemCallback)(void *pCallbackCtx, const QCBORItem *pItem);
+typedef QCBORError (*QCBORItemCallback)(void *pCallbackCtx,
+ const QCBORItem *pItem);
/**
@@ -1516,10 +1517,10 @@
Like QCBORDecode_GetItemsInMap(), this only matches and calls back on
the items at the top level of the map entered. Items in nested
- maps/arrays are skipped over and not candidate for matching or the
+ maps and arrays are skipped over and not candidate for matching or the
callback.
- See QCBORItemCallback() for error handling. TODO: does this set last error?
+ See QCBORItemCallback() for error handling.
*/
void QCBORDecode_GetItemsInMapWithCallback(QCBORDecodeContext *pCtx,
QCBORItem *pItemList,
@@ -1835,8 +1836,8 @@
// Semi private
#define QCBOR_TAGSPEC_NUM_TYPES 3
-// TODO: make content types 4 to help out epoch dates?
-/* TODO: This structure can probably be rearranged so the initialization
+// Improvement: make content types 4 to help out epoch dates?
+/* Improvement: This structure can probably be rearranged so the initialization
of it takes much less code. */
typedef struct {
/* One of QCBOR_TAGSPEC_MATCH_xxx */
@@ -1879,7 +1880,7 @@
static inline void
-QCBORDecode_GetBytes(QCBORDecodeContext *pMe, UsefulBufC *pValue)
+QCBORDecode_GetByteString(QCBORDecodeContext *pMe, UsefulBufC *pValue)
{
// Complier should make this just 64-bit integer parameter
const TagSpecification TagSpec =
@@ -1893,7 +1894,7 @@
}
inline static void
-QCBORDecode_GetBytesInMapN(QCBORDecodeContext *pMe,
+QCBORDecode_GetByteStringInMapN(QCBORDecodeContext *pMe,
int64_t nLabel,
UsefulBufC *pBstr)
{
@@ -1907,7 +1908,7 @@
}
inline static void
-QCBORDecode_GetBytesInMapSZ(QCBORDecodeContext *pMe,
+QCBORDecode_GetByteStringInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
UsefulBufC *pBstr)
{
@@ -1923,7 +1924,7 @@
static inline void
-QCBORDecode_GetText(QCBORDecodeContext *pMe, UsefulBufC *pValue)
+QCBORDecode_GetTextString(QCBORDecodeContext *pMe, UsefulBufC *pValue)
{
// Complier should make this just 64-bit integer parameter
const TagSpecification TagSpec =
@@ -1937,7 +1938,7 @@
}
inline static void
-QCBORDecode_GetTextInMapN(QCBORDecodeContext *pMe,
+QCBORDecode_GetTextStringInMapN(QCBORDecodeContext *pMe,
int64_t nLabel,
UsefulBufC *pText)
{
@@ -1954,7 +1955,7 @@
}
inline static void
-QCBORDecode_GetTextInMapSZ(QCBORDecodeContext *pMe,
+QCBORDecode_GetTextStringInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
UsefulBufC *pText)
{
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index e534199..a3edc6a 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -36,7 +36,8 @@
#include "ieee754.h" // Does not use math.h
#ifndef QCBOR_DISABLE_FLOAT_HW_USE
-#include <math.h> // For isnan(), llround(), llroudf(), round(), roundf() TODO: list
+#include <math.h> // For isnan(), llround(), llroudf(), round(), roundf(),
+ // pow(), exp2()
#include <fenv.h> // feclearexcept(), fetestexcept()
#endif
@@ -2502,7 +2503,7 @@
*/
do {
uReturn = QCBORDecode_GetNext(pMe, &Item);
- if( QCBORDecode_IsNotWellFormed(uReturn)) {
+ if(QCBORDecode_IsNotWellFormed(uReturn)) {
// TODO: also resource limit errors
goto Done;
}
@@ -2785,8 +2786,8 @@
*/
void QCBORDecode_GetItemInMapSZ(QCBORDecodeContext *pMe,
const char *szLabel,
- uint8_t uQcborType,
- QCBORItem *pItem)
+ uint8_t uQcborType,
+ QCBORItem *pItem)
{
if(pMe->uLastError != QCBOR_SUCCESS) {
return;
@@ -2954,7 +2955,9 @@
static void SearchAndEnter(QCBORDecodeContext *pMe, QCBORItem pSearch[])
{
- // TODO: check that only one item is in pSearch?
+ // The first item in pSearch is the one that is to be
+ // entered. It should be the only one filled in. Any other
+ // will be ignored unless it causes an error.
if(pMe->uLastError != QCBOR_SUCCESS) {
// Already in error state; do nothing.
return;
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index a965606..d046244 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -4661,9 +4661,9 @@
QCBORDecode_EnterMapFromMapSZ(&DCtx, "map in a map");
QCBORDecode_GetInt64InMapSZ(&DCtx, "another int", &nDecodedInt2);
- QCBORDecode_GetBytesInMapSZ(&DCtx, "bytes 1", &B1);
- QCBORDecode_GetBytesInMapSZ(&DCtx, "bytes 2", &B2);
- QCBORDecode_GetTextInMapSZ(&DCtx, "text 2", &S1);
+ QCBORDecode_GetByteStringInMapSZ(&DCtx, "bytes 1", &B1);
+ QCBORDecode_GetByteStringInMapSZ(&DCtx, "bytes 2", &B2);
+ QCBORDecode_GetTextStringInMapSZ(&DCtx, "text 2", &S1);
QCBORDecode_ExitMap(&DCtx);
QCBORDecode_EnterArrayFromMapSZ(&DCtx, "an array of two strings");
@@ -4676,8 +4676,8 @@
// Parse the same array again using GetText() instead of GetItem()
QCBORDecode_EnterArrayFromMapSZ(&DCtx, "an array of two strings");
- QCBORDecode_GetText(&DCtx, &S2);
- QCBORDecode_GetText(&DCtx, &S3);
+ QCBORDecode_GetTextString(&DCtx, &S2);
+ QCBORDecode_GetTextString(&DCtx, &S3);
if(QCBORDecode_GetError(&DCtx) != QCBOR_SUCCESS) {
return 5000;
}
@@ -4920,7 +4920,7 @@
return 2008;
}
UsefulBufC String;
- QCBORDecode_GetTextInMapN(&DCtx, 88, &String);
+ QCBORDecode_GetTextStringInMapN(&DCtx, 88, &String);
if(uErr != QCBOR_ERR_MAP_NOT_ENTERED){
return 2009;
}
@@ -4958,7 +4958,7 @@
QCBORDecode_Init(&DCtx, UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spArrayOfEmpty), 0);
QCBORDecode_EnterArray(&DCtx);
- QCBORDecode_GetBytes(&DCtx, &String);
+ QCBORDecode_GetByteString(&DCtx, &String);
QCBORDecode_EnterMap(&DCtx);
QCBORDecode_ExitMap(&DCtx);
QCBORDecode_EnterArray(&DCtx);
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 1e91378..2a5e5d9 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -514,7 +514,7 @@
int32_t AllAddMethodsTest()
{
- // TODO: this test should be broken down into several so it is more
+ // Improvement: this test should be broken down into several so it is more
// managable. Tags and labels could be more sensible
QCBOREncodeContext ECtx;
int nReturn = 0;
@@ -1950,7 +1950,7 @@
return nReturn;
}
if(Item.uDataType != QCBOR_TYPE_BYTE_STRING) {
- return -1; // TODO: better type?
+ return QCBOR_ERR_UNEXPECTED_TYPE;
}
*pBstr = Item.val.string;