From 12415612e1ec05ba30309f454d7240764e3029d8 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Tue, 15 Sep 2015 17:23:44 -0300 Subject: [PATCH] Add convenience function cbor_encode_text_stringz() This calculates the length of a text string to be encoded using strlen(). Useful when encoding constant strings. Signed-off-by: Leandro Pereira --- src/cbor.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cbor.h b/src/cbor.h index e82abbd0..11f3a849 100644 --- a/src/cbor.h +++ b/src/cbor.h @@ -153,6 +153,8 @@ CBOR_API CborError cbor_encode_int(CborEncoder *encoder, int64_t value); CBOR_API CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value); CBOR_API CborError cbor_encode_tag(CborEncoder *encoder, CborTag tag); CBOR_API CborError cbor_encode_text_string(CborEncoder *encoder, const char *string, size_t length); +CBOR_INLINE_API CborError cbor_encode_text_stringz(CborEncoder *encoder, const char *string) +{ return cbor_encode_text_string(encoder, string, strlen(string)); } CBOR_API CborError cbor_encode_byte_string(CborEncoder *encoder, const uint8_t *string, size_t length); CBOR_API CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value);