summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrimio <vasi.vilvoiu@gmail.com>2018-03-02 00:20:16 +0200
committerrimio <vasi.vilvoiu@gmail.com>2018-03-02 00:20:16 +0200
commite1c8564af2b02122e442503dd2c0fb77d2b935e4 (patch)
tree0efeaf0062c7fbea8a5a34b39a8d968d1e6c5291 /src
parent760860f3a34873e00cbf2ccb473f78cf3933a2f2 (diff)
Added UNDEFINED type; old error case renamed to NONE; added test case answers
Diffstat (limited to 'src')
-rw-r--r--src/ecbor.c4
-rw-r--r--src/ecbor_decoder.c13
-rw-r--r--src/ecbor_describe.c4
3 files changed, 13 insertions, 8 deletions
diff --git a/src/ecbor.c b/src/ecbor.c
index 2093366..96cc4cc 100644
--- a/src/ecbor.c
+++ b/src/ecbor.c
@@ -88,11 +88,11 @@ extern ecbor_type_t
ecbor_get_type (ecbor_item_t *item)
{
if (!item) {
- return ECBOR_TYPE_UNDEFINED;
+ return ECBOR_TYPE_NONE;
}
if (item->type < ECBOR_TYPE_FIRST
|| item->type > ECBOR_TYPE_LAST) {
- return ECBOR_TYPE_UNDEFINED;
+ return ECBOR_TYPE_NONE;
}
return item->type;
}
diff --git a/src/ecbor_decoder.c b/src/ecbor_decoder.c
index 9990ac5..437698d 100644
--- a/src/ecbor_decoder.c
+++ b/src/ecbor_decoder.c
@@ -211,6 +211,7 @@ ecbor_decode_simple_value (ecbor_item_t *item)
break;
case ECBOR_SIMPLE_UNDEFINED:
+ item->type = ECBOR_TYPE_UNDEFINED;
break;
default:
@@ -239,7 +240,7 @@ ecbor_decode_next_internal (ecbor_decode_context_t *context,
}
/* clear item, just so we do not leave garbage on partial read */
- item->type = ECBOR_TYPE_UNDEFINED;
+ item->type = ECBOR_TYPE_NONE;
item->size = 0;
item->length = 0;
item->is_indefinite = false;
@@ -384,7 +385,7 @@ ecbor_decode_next_internal (ecbor_decode_context_t *context,
while (true) {
/* read next chunk */
rc = ecbor_decode_next_internal (context, &child, false,
- ECBOR_TYPE_UNDEFINED);
+ ECBOR_TYPE_NONE);
if (rc != ECBOR_OK) {
if (rc == ECBOR_END_OF_INDEFINITE) {
/* stop code found, break from loop */
@@ -434,7 +435,7 @@ ecbor_decode_next_internal (ecbor_decode_context_t *context,
for (child_no = 0; child_no < item->length; child_no ++) {
/* read next child */
rc = ecbor_decode_next_internal (context, &child, false,
- ECBOR_TYPE_UNDEFINED);
+ ECBOR_TYPE_NONE);
if (rc != ECBOR_OK) {
if (rc == ECBOR_END_OF_INDEFINITE) {
/* stop code found, but none is expected */
@@ -476,7 +477,7 @@ ecbor_decode_next_internal (ecbor_decode_context_t *context,
/* not in streamed mode; compute size so we can advance */
rc = ecbor_decode_next_internal (context, &child, false,
- ECBOR_TYPE_UNDEFINED);
+ ECBOR_TYPE_NONE);
if (rc != ECBOR_OK) {
return rc;
}
@@ -550,7 +551,7 @@ ecbor_decode (ecbor_decode_context_t *context, ecbor_item_t *item)
}
/* we just get the next item */
- return ecbor_decode_next_internal (context, item, false, ECBOR_TYPE_UNDEFINED);
+ return ecbor_decode_next_internal (context, item, false, ECBOR_TYPE_NONE);
}
extern ecbor_error_t
@@ -587,7 +588,7 @@ ecbor_decode_tree (ecbor_decode_context_t *context)
/* consume next item */
rc = ecbor_decode_next_internal (context, &curr_node->item, false,
- ECBOR_TYPE_UNDEFINED);
+ ECBOR_TYPE_NONE);
/* handle end of indefinite */
if (rc == ECBOR_END_OF_INDEFINITE) {
diff --git a/src/ecbor_describe.c b/src/ecbor_describe.c
index fea511c..2ae9ccf 100644
--- a/src/ecbor_describe.c
+++ b/src/ecbor_describe.c
@@ -263,6 +263,10 @@ print_ecbor_item (ecbor_item_t *item, unsigned int level, char *prefix)
case ECBOR_TYPE_NULL:
printf ("[NULL]\n");
break;
+
+ case ECBOR_TYPE_UNDEFINED:
+ printf ("[UNDEFINED]\n");
+ break;
default:
printf ("[UNKNOWN]\n");