Added octetstring_copy_value() function to ease copying octetstring value into a buffer.

This commit is contained in:
skarg
2013-02-20 23:51:47 +00:00
parent f45aad0087
commit 209f9e82a2
2 changed files with 26 additions and 0 deletions
+4
View File
@@ -165,6 +165,10 @@ extern "C" {
bool octetstring_copy(
BACNET_OCTET_STRING * dest,
BACNET_OCTET_STRING * src);
size_t octetstring_copy_value(
uint8_t * dest,
size_t length,
BACNET_OCTET_STRING * src);
/* returns false if the string exceeds capacity */
bool octetstring_append(
BACNET_OCTET_STRING * octet_string,
+22
View File
@@ -730,6 +730,28 @@ bool octetstring_copy(
octetstring_length(src));
}
/* returns the number of bytes copied, or 0 if the dest
cannot hold entire octetstring value */
size_t octetstring_copy_value(
uint8_t * dest,
size_t length,
BACNET_OCTET_STRING * src)
{
size_t bytes_copied = 0;
size_t i; /* counter */
if (src && dest) {
if (length <= src->length) {
for (i = 0; i < src->length; i++) {
dest[i]= src->value[i];
}
bytes_copied = src->length;
}
}
return bytes_copied;
}
/* returns false if the string exceeds capacity */
bool octetstring_append(
BACNET_OCTET_STRING * octet_string,