|
@@ -140,15 +140,35 @@ const char *klysc_node_ext_default(const struct lysc_node *node)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+char *klyd_esc_value(const char *value)
|
|
|
|
+{
|
|
|
|
+ char *space = NULL;
|
|
|
|
+ char *escaped = NULL;
|
|
|
|
+ char *result = NULL;
|
|
|
|
+
|
|
|
|
+ if (!value)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ escaped = faux_str_c_esc(value);
|
|
|
|
+ // String with space must have quotes
|
|
|
|
+ space = strchr(escaped, ' ');
|
|
|
|
+ if (space) {
|
|
|
|
+ result = faux_str_sprintf("\"%s\"", escaped);
|
|
|
|
+ faux_str_free(escaped);
|
|
|
|
+ } else {
|
|
|
|
+ result = escaped;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
// Get value from data lyd node
|
|
// Get value from data lyd node
|
|
char *klyd_node_value(const struct lyd_node *node)
|
|
char *klyd_node_value(const struct lyd_node *node)
|
|
{
|
|
{
|
|
const struct lysc_node *schema = NULL;
|
|
const struct lysc_node *schema = NULL;
|
|
const struct lysc_type *type = NULL;
|
|
const struct lysc_type *type = NULL;
|
|
const char *origin_value = NULL;
|
|
const char *origin_value = NULL;
|
|
- char *space = NULL;
|
|
|
|
- char *escaped = NULL;
|
|
|
|
- char *result = NULL;
|
|
|
|
|
|
|
|
if (!node)
|
|
if (!node)
|
|
return NULL;
|
|
return NULL;
|
|
@@ -171,17 +191,7 @@ char *klyd_node_value(const struct lyd_node *node)
|
|
origin_value = value->ident->name;
|
|
origin_value = value->ident->name;
|
|
}
|
|
}
|
|
|
|
|
|
- escaped = faux_str_c_esc(origin_value);
|
|
|
|
- // String with space must have quotes
|
|
|
|
- space = strchr(origin_value, ' ');
|
|
|
|
- if (space) {
|
|
|
|
- result = faux_str_sprintf("\"%s\"", escaped);
|
|
|
|
- faux_str_free(escaped);
|
|
|
|
- } else {
|
|
|
|
- result = escaped;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return result;
|
|
|
|
|
|
+ return klyd_esc_value(origin_value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|