Merge branch 'master' into dev
diff --git a/inc/qcbor/qcbor_decode.h b/inc/qcbor/qcbor_decode.h
index e9c40fc..a7b85ee 100644
--- a/inc/qcbor/qcbor_decode.h
+++ b/inc/qcbor/qcbor_decode.h
@@ -211,6 +211,7 @@
/* Do not renumber these. Code depends on some of these values. */
/** The data type is unknown, unset or invalid. */
#define QCBOR_TYPE_NONE 0
+
/** Never used in QCBORItem. Used by functions that match QCBOR types. */
#define QCBOR_TYPE_ANY 1
@@ -218,35 +219,51 @@
* @c INT32_MIN or @c INT32_MAX and @c INT64_MAX. Data is in member
* @c val.int64. */
#define QCBOR_TYPE_INT64 2
+
/** Type for an integer that decoded to a more than @c INT64_MAX and
* @c UINT64_MAX. Data is in member @c val.uint64. */
#define QCBOR_TYPE_UINT64 3
+
/** Type for an array. See comments on @c val.uCount. */
#define QCBOR_TYPE_ARRAY 4
+
/** Type for a map. See comments on @c val.uCount. */
#define QCBOR_TYPE_MAP 5
+
/** Type for a buffer full of bytes. Data is in @c val.string. */
#define QCBOR_TYPE_BYTE_STRING 6
+
/** Type for a UTF-8 string. It is not NULL-terminated. See
* QCBOREncode_AddText() for a discussion of line endings in CBOR. Data
* is in @c val.string. */
#define QCBOR_TYPE_TEXT_STRING 7
+
/** Type for a positive big number. Data is in @c val.bignum, a
* pointer and a length. */
#define QCBOR_TYPE_POSBIGNUM 9
+
/** Type for a negative big number. Data is in @c val.bignum, a
* pointer and a length. */
#define QCBOR_TYPE_NEGBIGNUM 10
+
/** Type for [RFC 3339] (https://tools.ietf.org/html/rfc3339) date
* string, possibly with time zone. Data is in @c val.string . Note this
* was previously in @c val.dateString, however this is the same as
- * val.string being the same type in same union. */
+ * val.string being the same type in same union. val.dateString will
+ * be deprecated.. */
#define QCBOR_TYPE_DATE_STRING 11
+
/** Type for integer seconds since Jan 1970 + floating-point
* fraction. Data is in @c val.epochDate */
#define QCBOR_TYPE_DATE_EPOCH 12
-/** A simple type that this CBOR implementation doesn't know about;
- * Type is in @c val.uSimple. */
+
+/** The CBOR major type "simple" has a small integer value indicating
+ * what it is. The standard CBOR simples are true, false, null, undef
+ * (values 20-23) and float-point numbers (values 25-27). The values
+ * 0-19 and 32-255 are unassigned and may be used if registered with
+ * in the IANA Simple Values Registry. If these unassigned simple
+ * values occur in the input they will be decoded as this. The value
+ * is in @c val.uSimple. */
#define QCBOR_TYPE_UKNOWN_SIMPLE 13
/** A decimal fraction made of decimal exponent and integer mantissa.
@@ -278,16 +295,21 @@
* QCBOREncode_AddBigFloatBigNum(). */
#define QCBOR_TYPE_BIGFLOAT_NEG_BIGNUM 19
-/** Type for the value false. */
+/** Type for the simple value false. */
#define QCBOR_TYPE_FALSE 20
-/** Type for the value true. */
+
+/** Type for the simple value true. */
#define QCBOR_TYPE_TRUE 21
-/** Type for the value null. */
+
+/** Type for the simple value null. */
#define QCBOR_TYPE_NULL 22
-/** Type for the value undef. */
+
+/** Type for the simple value undef. */
#define QCBOR_TYPE_UNDEF 23
+
/** Type for a floating-point number. Data is in @c val.float. */
#define QCBOR_TYPE_FLOAT 26
+
/** Type for a double floating-point number. Data is in @c val.double. */
#define QCBOR_TYPE_DOUBLE 27
@@ -448,15 +470,13 @@
/** The value for @c uDataType @ref QCBOR_TYPE_DAYS_EPOCH -- the
* number of days before or after Jan 1, 1970. */
int64_t epochDays;
-
/** No longer used. Was the value for @ref QCBOR_TYPE_DATE_STRING,
- * but now that value is in @c string. TODO: finish writing this.*/
+ * but now that value is in @c string. This will be removed in QCBOR 2.0. */
UsefulBufC dateString;
-
/** The value for @c uDataType @ref QCBOR_TYPE_POSBIGNUM and
- @ref QCBOR_TYPE_NEGBIGNUM. TODO: change to string*/
+ * @ref QCBOR_TYPE_NEGBIGNUM. */
UsefulBufC bigNum;
- /** The integer value for unknown simple types. TODO: doc this better. */
+ /** See @ref QCBOR_TYPE_UKNOWN_SIMPLE */
uint8_t uSimple;
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
/**
diff --git a/src/qcbor_encode.c b/src/qcbor_encode.c
index a2a944a..eee047c 100644
--- a/src/qcbor_encode.c
+++ b/src/qcbor_encode.c
@@ -249,7 +249,7 @@
/*
- Public function for initialization. See qcbor/qcbor_encode.h
+ * Public function for initialization. See qcbor/qcbor_encode.h
*/
void
QCBOREncode_Init(QCBOREncodeContext *pMe, UsefulBuf Storage)
@@ -1413,9 +1413,10 @@
{
*pPlace = UsefulOutBuf_GetOutPlace(&(pMe->OutBuf));
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
- // TODO: is this right?
uint8_t uMajorType = Nesting_GetMajorType(&(pMe->nesting));
if(uMajorType == CBOR_MAJOR_NONE_TYPE_OPEN_BSTR) {
+ /* It's OK to nest a byte string in any type but
+ * another open byte string. */
pMe->uError = QCBOR_ERR_OPEN_BYTE_STRING;
return;
}
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index b489657..8e33858 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -2445,7 +2445,7 @@
return -1;
}
if(Item.uDataType != QCBOR_TYPE_DATE_STRING ||
- UsefulBufCompareToSZ(Item.val.dateString, "1985-04-12")){
+ UsefulBufCompareToSZ(Item.val.string, "1985-04-12")){
return -2;
}