Skip to content

Commit 25afd0c

Browse files
committed
SOVERSION bump to version 5.1.1
1 parent 89fe436 commit 25afd0c

File tree

9 files changed

+81
-65
lines changed

9 files changed

+81
-65
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_
6767
# set version of the library
6868
set(LIBYANG_MAJOR_SOVERSION 5)
6969
set(LIBYANG_MINOR_SOVERSION 1)
70-
set(LIBYANG_MICRO_SOVERSION 0)
70+
set(LIBYANG_MICRO_SOVERSION 1)
7171
set(LIBYANG_SOVERSION_FULL ${LIBYANG_MAJOR_SOVERSION}.${LIBYANG_MINOR_SOVERSION}.${LIBYANG_MICRO_SOVERSION})
7272
set(LIBYANG_SOVERSION ${LIBYANG_MAJOR_SOVERSION})
7373

src/diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ lyd_diff_attrs(const struct lyd_node *first, const struct lyd_node *second, uint
949949
*orig_value = strdup(str_val ? str_val : "");
950950
LY_CHECK_ERR_RET(!*orig_value, LOGMEM(schema->module->ctx), LY_EMEM);
951951
} else {
952-
LY_CHECK_RET(lyd_any_value_str(first, orig_value));
952+
LY_CHECK_RET(lyd_any_value_str(first, LYD_XML, orig_value));
953953
}
954954
}
955955

@@ -3043,7 +3043,7 @@ lyd_diff_reverse_value(struct lyd_node *node, const struct lys_module *mod)
30433043
if (node->schema->nodetype == LYS_LEAF) {
30443044
val2 = strdup(lyd_get_value(node));
30453045
} else {
3046-
LY_CHECK_RET(lyd_any_value_str(node, &val2));
3046+
LY_CHECK_RET(lyd_any_value_str(node, LYD_XML, &val2));
30473047
}
30483048

30493049
/* switch values, keep default flag */

src/tree_data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ lyd_parse_value_fragment(const struct ly_ctx *ctx, const char *path, struct ly_i
290290

291291
if (LY_ARRAY_COUNT(p)) {
292292
/* create nodes */
293-
LY_CHECK_GOTO(ret = lyd_new_path_create(NULL, ctx, p, path, NULL, 0, new_val_options, &new_top_parent,
293+
LY_CHECK_GOTO(ret = lyd_new_path_create(NULL, ctx, p, path, NULL, 0, 0, new_val_options, &new_top_parent,
294294
&new_last_parent), cleanup);
295295
}
296296

src/tree_data.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,8 @@ struct lyd_node_any {
889889
struct lyd_node *child; /**< pointer to the first child node, if any */
890890
struct ly_ht *children_ht; /**< unused, always NULL */
891891
const char *value; /**< pointer to the string value, if any */
892-
uint32_t hints; /**< additional value format information, see the [hints list](@ref lydhints) */
892+
uint32_t hints; /**< additional value format information, see the [val hints](@ref lydvalhints)
893+
and [node hints](@ref lydnodehints) */
893894
};
894895

895896
/**
@@ -1182,10 +1183,11 @@ lyd_get_value(const struct lyd_node *node)
11821183
* @brief Get anydata string value.
11831184
*
11841185
* @param[in] any Anyxml/anydata node to read from.
1186+
* @param[in] format Format to use in case the value is a data tree.
11851187
* @param[out] value_str String representation of the value.
11861188
* @return LY_ERR value.
11871189
*/
1188-
LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1190+
LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, LYD_FORMAT format, char **value_str);
11891191

11901192
/**
11911193
* @brief Copy anydata value from one node to another. Target value is freed first.
@@ -1365,12 +1367,13 @@ LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct l
13651367
* @param[in] name Schema node name of the new data node. The node can be #LYS_ANYDATA or #LYS_ANYXML.
13661368
* @param[in] child Data tree value of the node, not set if @p value is set.
13671369
* @param[in] value String value for the node, not set if @p child is set.
1370+
* @param[in] hints String @p value hints (@ref lydvalhints or @ref lydnodehints), if any.
13681371
* @param[in] options Bitmask of options, see @ref newvaloptions.
13691372
* @param[out] node Optional created node.
13701373
* @return LY_ERR value.
13711374
*/
13721375
LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1373-
const struct lyd_node *child, const char *value, uint32_t options, struct lyd_node **node);
1376+
const struct lyd_node *child, const char *value, uint32_t hints, uint32_t options, struct lyd_node **node);
13741377

13751378
/**
13761379
* @brief Create a new metadata.
@@ -1510,6 +1513,7 @@ LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ct
15101513
* but can be a data tree based on @p options. For other node types, it should be NULL.
15111514
* @param[in] value_size_bits Size of @p value in bits. Does not have to be set if a 0-terminated string and XML or
15121515
* JSON value format. Ignored when creating anyxml/anydata nodes.
1516+
* @param[in] any_hints Hints for @p value when creating an anyxml/anydata node.
15131517
* @param[in] options Bitmask of options, see @ref newvaloptions.
15141518
* @param[out] new_parent Optional first parent node created. If only one node was created, equals to @p new_node.
15151519
* @param[out] new_node Optional target node of @p path (the last created node, the list instance in case of a list).
@@ -1519,8 +1523,9 @@ LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ct
15191523
* @return LY_EVALID on invalid @p value.
15201524
* @return LY_ERR on other errors.
15211525
*/
1522-
LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1523-
uint32_t value_size_bits, uint32_t options, struct lyd_node **new_parent, struct lyd_node **new_node);
1526+
LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path,
1527+
const void *value, uint32_t value_size_bits, uint32_t any_hints, uint32_t options, struct lyd_node **new_parent,
1528+
struct lyd_node **new_node);
15241529

15251530
/**
15261531
* @ingroup datatree

src/tree_data_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value)
978978
}
979979

980980
LIBYANG_API_DEF LY_ERR
981-
lyd_any_value_str(const struct lyd_node *any, char **value_str)
981+
lyd_any_value_str(const struct lyd_node *any, LYD_FORMAT format, char **value_str)
982982
{
983983
const struct lyd_node_any *a;
984984

@@ -996,7 +996,7 @@ lyd_any_value_str(const struct lyd_node *any, char **value_str)
996996

997997
if (a->child) {
998998
/* print into a string */
999-
LY_CHECK_RET(lyd_print_mem(value_str, a->child, LYD_XML, LYD_PRINT_SIBLINGS));
999+
LY_CHECK_RET(lyd_print_mem(value_str, a->child, format, LYD_PRINT_SIBLINGS));
10001000
} else {
10011001
/* simply use the string */
10021002
*value_str = strdup(a->value);

src/tree_data_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,14 @@ LY_ERR lyd_change_term_val(struct lyd_node *term, struct lyd_value *val, ly_bool
353353
* anyxml/anydata node, the expected type depends on @p value_type. For other node types, it should be NULL.
354354
* @param[in] value_size_bits Size of @p value in bits, must be set correctly. Ignored when
355355
* creating anyxml/anydata nodes.
356+
* @param[in] any_hints Hints for @p value when creating an anyxml/anydata node.
356357
* @param[in] options Bitmask of new value creation options, see @ref newvaloptions.
357358
* @param[out] new_parent Optional first parent node created. If only one node was created, equals to @p new_node.
358359
* @param[out] new_node Optional last node created.
359360
* @return LY_ERR value.
360361
*/
361362
LY_ERR lyd_new_path_create(struct lyd_node *parent, const struct ly_ctx *ctx, struct ly_path *p, const char *path,
362-
const void *value, uint32_t value_size_bits, uint32_t options, struct lyd_node **new_parent,
363+
const void *value, uint32_t value_size_bits, uint32_t any_hints, uint32_t options, struct lyd_node **new_parent,
363364
struct lyd_node **new_node);
364365

365366
/**

src/tree_data_new.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const
758758

759759
LIBYANG_API_DEF LY_ERR
760760
lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const struct lyd_node *child,
761-
const char *value, uint32_t options, struct lyd_node **node)
761+
const char *value, uint32_t hints, uint32_t options, struct lyd_node **node)
762762
{
763763
LY_ERR r;
764764
struct lyd_node *ret = NULL;
@@ -782,7 +782,7 @@ lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char
782782
}
783783
LY_CHECK_ERR_RET(r, LOGERR(ctx, LY_EINVAL, "Any node \"%s\" not found.", name), LY_ENOTFOUND);
784784

785-
LY_CHECK_RET(lyd_create_any(schema, child, value, 0, use_value, 1, &ret));
785+
LY_CHECK_RET(lyd_create_any(schema, child, value, hints, use_value, 1, &ret));
786786
if (ext) {
787787
ret->flags |= LYD_EXT;
788788
}
@@ -1292,6 +1292,7 @@ lyd_anydata_switch_value(struct lyd_node *node1, struct lyd_node *node2)
12921292
struct lyd_node_any *any1, *any2;
12931293
const char *value;
12941294
struct lyd_node *child, *iter;
1295+
uint32_t hints;
12951296

12961297
assert((node1->schema->nodetype & LYD_NODE_ANY) && (node2->schema->nodetype & LYD_NODE_ANY));
12971298

@@ -1301,20 +1302,23 @@ lyd_anydata_switch_value(struct lyd_node *node1, struct lyd_node *node2)
13011302
/* backup any1 */
13021303
child = any1->child;
13031304
value = any1->value;
1305+
hints = any1->hints;
13041306

13051307
/* set any1 */
13061308
any1->child = any2->child;
13071309
LY_LIST_FOR(any1->child, iter) {
13081310
iter->parent = &any1->node;
13091311
}
13101312
any1->value = any2->value;
1313+
any1->hints = any2->hints;
13111314

13121315
/* set any2 */
13131316
any2->child = child;
13141317
LY_LIST_FOR(any2->child, iter) {
13151318
iter->parent = &any2->node;
13161319
}
13171320
any2->value = value;
1321+
any2->hints = hints;
13181322
}
13191323

13201324
/**
@@ -1323,6 +1327,7 @@ lyd_anydata_switch_value(struct lyd_node *node1, struct lyd_node *node2)
13231327
* @param[in] node Node to update.
13241328
* @param[in] value New value to set.
13251329
* @param[in] value_size_bits Size of @p value in bits.
1330+
* @param[in] any_hints Hints for @p value when updating an anyxml/anydata node.
13261331
* @param[in] options New path options.
13271332
* @param[in] format Format of @p value.
13281333
* @param[in] any_use_value Whether to spend @p value when updating an anydata/anyxml node or not.
@@ -1331,7 +1336,7 @@ lyd_anydata_switch_value(struct lyd_node *node1, struct lyd_node *node2)
13311336
* @return LY_ERR value.
13321337
*/
13331338
static LY_ERR
1334-
lyd_new_path_update(struct lyd_node *node, const void *value, uint32_t value_size_bits, uint32_t options,
1339+
lyd_new_path_update(struct lyd_node *node, const void *value, uint32_t value_size_bits, uint32_t any_hints, uint32_t options,
13351340
LY_VALUE_FORMAT format, ly_bool any_use_value, struct lyd_node **new_parent, struct lyd_node **new_node)
13361341
{
13371342
LY_ERR ret = LY_SUCCESS;
@@ -1381,7 +1386,7 @@ lyd_new_path_update(struct lyd_node *node, const void *value, uint32_t value_siz
13811386
child = NULL;
13821387
val_str = value;
13831388
}
1384-
LY_CHECK_RET(lyd_create_any(node->schema, child, val_str, 0, any_use_value, 1, &new_any));
1389+
LY_CHECK_RET(lyd_create_any(node->schema, child, val_str, any_hints, any_use_value, 1, &new_any));
13851390

13861391
/* compare with the existing one */
13871392
if (lyd_compare_single(node, new_any, 0)) {
@@ -1492,7 +1497,7 @@ lyd_new_path_check_find_lypath(struct ly_path *path, const char *str_path, const
14921497

14931498
LY_ERR
14941499
lyd_new_path_create(struct lyd_node *parent, const struct ly_ctx *ctx, struct ly_path *p, const char *path,
1495-
const void *value, uint32_t value_size_bits, uint32_t options, struct lyd_node **new_parent,
1500+
const void *value, uint32_t value_size_bits, uint32_t any_hints, uint32_t options, struct lyd_node **new_parent,
14961501
struct lyd_node **new_node)
14971502
{
14981503
LY_ERR ret = LY_SUCCESS, r;
@@ -1531,7 +1536,8 @@ lyd_new_path_create(struct lyd_node *parent, const struct ly_ctx *ctx, struct ly
15311536
}
15321537

15331538
/* update the existing node */
1534-
ret = lyd_new_path_update(node, value, value_size_bits, options, format, any_use_value, &nparent, &nnode);
1539+
ret = lyd_new_path_update(node, value, value_size_bits, any_hints, options, format, any_use_value,
1540+
&nparent, &nnode);
15351541
goto cleanup;
15361542
} /* else we were not searching for the whole path */
15371543
} else if (r == LY_EINCOMPLETE) {
@@ -1676,10 +1682,10 @@ lyd_new_path_create(struct lyd_node *parent, const struct ly_ctx *ctx, struct ly
16761682
case LYS_ANYXML:
16771683
if (path_idx < LY_ARRAY_COUNT(p) - 1) {
16781684
/* creating descendants of the node directly, use no value now */
1679-
LY_CHECK_GOTO(ret = lyd_create_any(schema, NULL, NULL, 0, 1, 0, &node), cleanup);
1685+
LY_CHECK_GOTO(ret = lyd_create_any(schema, NULL, NULL, any_hints, 1, 0, &node), cleanup);
16801686
} else {
16811687
LY_CHECK_GOTO(ret = lyd_create_any(schema, (options & LYD_NEW_PATH_ANY_DATATREE) ? value : NULL,
1682-
(options & LYD_NEW_PATH_ANY_DATATREE) ? NULL : value, 0, any_use_value, 1, &node), cleanup);
1688+
(options & LYD_NEW_PATH_ANY_DATATREE) ? NULL : value, any_hints, any_use_value, 1, &node), cleanup);
16831689
}
16841690
break;
16851691
default:
@@ -1746,14 +1752,16 @@ lyd_new_path_create(struct lyd_node *parent, const struct ly_ctx *ctx, struct ly
17461752
* anyxml/anydata node, the expected type depends on @p options. For other node types, it should be NULL.
17471753
* @param[in] value_size_bits Size of @p value in bits, must be set correctly. Ignored when
17481754
* creating anyxml/anydata nodes.
1755+
* @param[in] any_hints Hints for @p value when creating an anyxml/anydata node.
17491756
* @param[in] options Bitmask of options, see @ref pathoptions.
17501757
* @param[out] new_parent Optional first parent node created. If only one node was created, equals to @p new_node.
17511758
* @param[out] new_node Optional last node created.
17521759
* @return LY_ERR value.
17531760
*/
17541761
static LY_ERR
17551762
lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1756-
uint32_t value_size_bits, uint32_t options, struct lyd_node **new_parent, struct lyd_node **new_node)
1763+
uint32_t value_size_bits, uint32_t any_hints, uint32_t options, struct lyd_node **new_parent,
1764+
struct lyd_node **new_node)
17571765
{
17581766
LY_ERR ret = LY_SUCCESS;
17591767
struct lyxp_expr *exp = NULL;
@@ -1775,7 +1783,7 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const char *pat
17751783
LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT, LY_PATH_TARGET_MANY, 0, LY_VALUE_JSON, NULL, &p), cleanup);
17761784

17771785
/* create nodes */
1778-
LY_CHECK_GOTO(ret = lyd_new_path_create(parent, ctx, p, path, value, value_size_bits, options, new_parent,
1786+
LY_CHECK_GOTO(ret = lyd_new_path_create(parent, ctx, p, path, value, value_size_bits, any_hints, options, new_parent,
17791787
new_node), cleanup);
17801788

17811789
cleanup:
@@ -1791,12 +1799,13 @@ lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path
17911799
LY_CHECK_ARG_RET(ctx, parent || ctx, path, (path[0] == '/') || parent, !(options & LYD_NEW_VAL_BIN), LY_EINVAL);
17921800
LY_CHECK_CTX_EQUAL_RET(__func__, parent ? LYD_CTX(parent) : NULL, ctx, LY_EINVAL);
17931801

1794-
return lyd_new_path_(parent, ctx, path, value, value ? strlen(value) * 8 : 0, options, node, NULL);
1802+
return lyd_new_path_(parent, ctx, path, value, value ? strlen(value) * 8 : 0, 0, options, node, NULL);
17951803
}
17961804

17971805
LIBYANG_API_DEF LY_ERR
17981806
lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1799-
uint32_t value_size_bits, uint32_t options, struct lyd_node **new_parent, struct lyd_node **new_node)
1807+
uint32_t value_size_bits, uint32_t any_hints, uint32_t options, struct lyd_node **new_parent,
1808+
struct lyd_node **new_node)
18001809
{
18011810
LY_CHECK_ARG_RET(ctx, parent || ctx, path, (path[0] == '/') || parent,
18021811
!(options & LYD_NEW_VAL_BIN) || !(options & LYD_NEW_VAL_CANON), LY_EINVAL);
@@ -1806,7 +1815,7 @@ lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *pat
18061815
value_size_bits = strlen(value) * 8;
18071816
}
18081817

1809-
return lyd_new_path_(parent, ctx, path, value, value_size_bits, options, new_parent, new_node);
1818+
return lyd_new_path_(parent, ctx, path, value, value_size_bits, any_hints, options, new_parent, new_node);
18101819
}
18111820

18121821
LY_ERR

0 commit comments

Comments
 (0)