diff options
Diffstat (limited to 'src/3rdparty/tinycbor/src/cbor.h')
-rw-r--r-- | src/3rdparty/tinycbor/src/cbor.h | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/3rdparty/tinycbor/src/cbor.h b/src/3rdparty/tinycbor/src/cbor.h index d7dee0f55b..5c7ba74e39 100644 --- a/src/3rdparty/tinycbor/src/cbor.h +++ b/src/3rdparty/tinycbor/src/cbor.h @@ -234,6 +234,7 @@ typedef struct CborEncoder CborEncoder; static const size_t CborIndefiniteLength = SIZE_MAX; +#ifndef CBOR_NO_ENCODER_API CBOR_API void cbor_encoder_init(CborEncoder *encoder, uint8_t *buffer, size_t size, int flags); CBOR_API void cbor_encoder_init_writer(CborEncoder *encoder, CborEncoderWriteFunction writer, void *); CBOR_API CborError cbor_encode_uint(CborEncoder *encoder, uint64_t value); @@ -280,6 +281,7 @@ CBOR_INLINE_API size_t cbor_encoder_get_extra_bytes_needed(const CborEncoder *en { return encoder->end ? 0 : (size_t)encoder->data.bytes_needed; } +#endif /* CBOR_NO_ENCODER_API */ /* Parser API */ @@ -344,7 +346,8 @@ struct CborValue }; typedef struct CborValue CborValue; -CBOR_API CborError cbor_parser_init(const uint8_t *buffer, size_t size, int flags, CborParser *parser, CborValue *it); +#ifndef CBOR_NO_PARSER_API +CBOR_API CborError cbor_parser_init(const uint8_t *buffer, size_t size, uint32_t flags, CborParser *parser, CborValue *it); CBOR_API CborError cbor_parser_init_reader(const struct CborParserOperations *ops, CborParser *parser, CborValue *it, void *token); CBOR_API CborError cbor_value_validate_basic(const CborValue *it); @@ -464,10 +467,11 @@ CBOR_INLINE_API bool cbor_value_is_text_string(const CborValue *value) CBOR_INLINE_API CborError cbor_value_get_string_length(const CborValue *value, size_t *length) { + uint64_t v; assert(cbor_value_is_byte_string(value) || cbor_value_is_text_string(value)); if (!cbor_value_is_length_known(value)) return CborErrorUnknownLength; - uint64_t v = _cbor_value_extract_int64_helper(value); + v = _cbor_value_extract_int64_helper(value); *length = (size_t)v; if (*length != v) return CborErrorDataTooLarge; @@ -560,10 +564,11 @@ CBOR_INLINE_API bool cbor_value_is_map(const CborValue *value) CBOR_INLINE_API CborError cbor_value_get_array_length(const CborValue *value, size_t *length) { + uint64_t v; assert(cbor_value_is_array(value)); if (!cbor_value_is_length_known(value)) return CborErrorUnknownLength; - uint64_t v = _cbor_value_extract_int64_helper(value); + v = _cbor_value_extract_int64_helper(value); *length = (size_t)v; if (*length != v) return CborErrorDataTooLarge; @@ -572,10 +577,11 @@ CBOR_INLINE_API CborError cbor_value_get_array_length(const CborValue *value, si CBOR_INLINE_API CborError cbor_value_get_map_length(const CborValue *value, size_t *length) { + uint64_t v; assert(cbor_value_is_map(value)); if (!cbor_value_is_length_known(value)) return CborErrorUnknownLength; - uint64_t v = _cbor_value_extract_int64_helper(value); + v = _cbor_value_extract_int64_helper(value); *length = (size_t)v; if (*length != v) return CborErrorDataTooLarge; @@ -601,9 +607,10 @@ CBOR_INLINE_API bool cbor_value_is_float(const CborValue *value) { return value->type == CborFloatType; } CBOR_INLINE_API CborError cbor_value_get_float(const CborValue *value, float *result) { + uint32_t data; assert(cbor_value_is_float(value)); assert(value->flags & CborIteratorFlag_IntegerValueTooLarge); - uint32_t data = (uint32_t)_cbor_value_decode_int64_internal(value); + data = (uint32_t)_cbor_value_decode_int64_internal(value); memcpy(result, &data, sizeof(*result)); return CborNoError; } @@ -612,14 +619,16 @@ CBOR_INLINE_API bool cbor_value_is_double(const CborValue *value) { return value->type == CborDoubleType; } CBOR_INLINE_API CborError cbor_value_get_double(const CborValue *value, double *result) { + uint64_t data; assert(cbor_value_is_double(value)); assert(value->flags & CborIteratorFlag_IntegerValueTooLarge); - uint64_t data = _cbor_value_decode_int64_internal(value); + data = _cbor_value_decode_int64_internal(value); memcpy(result, &data, sizeof(*result)); return CborNoError; } /* Validation API */ +#ifndef CBOR_NO_VALIDATION_API enum CborValidationFlags { /* Bit mapping: @@ -662,9 +671,11 @@ enum CborValidationFlags { CborValidateBasic = 0 }; -CBOR_API CborError cbor_value_validate(const CborValue *it, int flags); +CBOR_API CborError cbor_value_validate(const CborValue *it, uint32_t flags); +#endif /* CBOR_NO_VALIDATION_API */ /* Human-readable (dump) API */ +#ifndef CBOR_NO_PRETTY_API enum CborPrettyFlags { CborPrettyNumericEncodingIndicators = 0x01, @@ -699,6 +710,10 @@ CBOR_INLINE_API CborError cbor_value_to_pretty(FILE *out, const CborValue *value } #endif /* __STDC_HOSTED__ check */ +#endif /* CBOR_NO_PRETTY_API */ + +#endif /* CBOR_NO_PARSER_API */ + #ifdef __cplusplus } #endif |