From bf309e08a79358315f773c8763133351cbc74152 Mon Sep 17 00:00:00 2001 From: slegouix Date: Thu, 21 Mar 2024 15:33:22 +0100 Subject: [PATCH] add support for tags of 64 bits wide --- include/nanocbor/nanocbor.h | 12 ++++++++++++ src/decoder.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/include/nanocbor/nanocbor.h b/include/nanocbor/nanocbor.h index 6ccf7d1..7ac8ac9 100644 --- a/include/nanocbor/nanocbor.h +++ b/include/nanocbor/nanocbor.h @@ -498,6 +498,18 @@ void nanocbor_leave_container(nanocbor_value_t *it, */ int nanocbor_get_tag(nanocbor_value_t *cvalue, uint32_t *tag); +/** + * @brief Retrieve a tag as positive uint64_t from the stream + * + * The resulting @p value is undefined if the result is an error condition + * + * @param[in] cvalue CBOR value to decode from + * @param[out] tag returned tag as positive integer + * + * @return NANOCBOR_OK on success + */ +int nanocbor_get_tag64(nanocbor_value_t *cvalue, uint64_t *tag); + /** * @brief Retrieve a null value from the stream * diff --git a/src/decoder.c b/src/decoder.c index de06302..5820659 100644 --- a/src/decoder.c +++ b/src/decoder.c @@ -271,6 +271,11 @@ int nanocbor_get_tag(nanocbor_value_t *cvalue, uint32_t *tag) return res; } +int nanocbor_get_tag64(nanocbor_value_t *cvalue, uint64_t *tag) +{ + return _get_and_advance_uint64(cvalue, tag, NANOCBOR_TYPE_TAG); +} + int nanocbor_get_decimal_frac(nanocbor_value_t *cvalue, int32_t *e, int32_t *m) { int res = NANOCBOR_NOT_FOUND;