Feature/writable structured view object lists (#1256)
* Added WriteProperty handler in the Structured View object with handling for object-name, description, node-subtype, node-type, default-subordinate-relationship, represents, subordinate-list, subordinate-annotations, subordinate-node-types, and subordinate-relationships in the basic Structured View object. * Changed Structured View character strings for object-name, description, and node-subtype to use dynamic strings to support WriteProperty. * Added characterstring_utf8_valid(), characterstring_utf8_strdup() and write_property_characterstring_utf8_strdup() for UTF-8 string duplication. * Added write property tests for array handling and validation of array index values
This commit is contained in:
@@ -361,6 +361,43 @@ bool write_property_type_valid(
|
||||
return (valid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief simple validation of character string value for Write Property
|
||||
* @param wp_data - #BACNET_WRITE_PROPERTY_DATA data, including
|
||||
* requested data and space for the reply, or error response.
|
||||
* @param value - #BACNET_CHARACTER_STRING data
|
||||
* @return pointer to duplicated UTF-8 string, or NULL if invalid
|
||||
*/
|
||||
char *write_property_characterstring_utf8_strdup(
|
||||
BACNET_WRITE_PROPERTY_DATA *wp_data, const BACNET_CHARACTER_STRING *value)
|
||||
{
|
||||
char *str = NULL; /* return value */
|
||||
|
||||
if (characterstring_encoding(value) == CHARACTER_UTF8) {
|
||||
if (utf8_isvalid(value->value, value->length)) {
|
||||
str = characterstring_utf8_strdup(value);
|
||||
if (!str) {
|
||||
if (wp_data) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (wp_data) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (wp_data) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief simple validation of character string value for Write Property
|
||||
* @param wp_data - #BACNET_WRITE_PROPERTY_DATA data, including
|
||||
|
||||
Reference in New Issue
Block a user