1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cbor: add API to encode non null-terminated byte strings

This commit is contained in:
Tobias Markmann 2015-08-06 22:19:52 +02:00
parent 683c71856a
commit f5418fa666
2 changed files with 16 additions and 0 deletions

View File

@ -576,6 +576,11 @@ size_t cbor_serialize_byte_string(cbor_stream_t *stream, const char *val)
return encode_bytes(CBOR_BYTES, stream, val, strlen(val));
}
size_t cbor_serialize_byte_stringl(cbor_stream_t *stream, const char *val, size_t length)
{
return encode_bytes(CBOR_BYTES, stream, val, length);
}
size_t cbor_deserialize_unicode_string(const cbor_stream_t *stream, size_t offset, char *val,
size_t length)
{

View File

@ -370,6 +370,17 @@ size_t cbor_deserialize_double(const cbor_stream_t *stream, size_t offset,
*/
size_t cbor_serialize_byte_string(cbor_stream_t *stream, const char *val);
/**
* @brief Serializes an arbitrary byte string
*
* @param[out] stream The destination stream for serializing the byte stream
* @param[in] val The arbitrary byte string which may include null bytes
* @param[in] length The size of the byte string in bytes
*
* @return Number of bytes written to stream @p stream
*/
size_t cbor_serialize_byte_stringl(cbor_stream_t *stream, const char *val, size_t length);
/**
* @brief Deserialize bytes from @p stream to @p val
*