Skip to content

Commit

Permalink
Fix the addition or deletion of leaf-lists from Netconf.
Browse files Browse the repository at this point in the history
This change modifies _sch_xml_to_gnode and fixes the addition and deletion
of leaf-lists. A number of new tests will be added to the apteryx-netconf
repository to test the new functionality.
  • Loading branch information
gcampbell512 committed Apr 11, 2024
1 parent 0dfe3c6 commit 5ac5359
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -3406,10 +3406,36 @@ _sch_xml_to_gnode (_sch_xml_to_gnode_parms *_parms, sch_node * schema, xmlNs *ns
/* LIST */
if (sch_is_leaf_list (schema))
{
char *old_xpath = new_xpath;
char *key_value = NULL;

DEBUG (_parms->in_flags, "%*s%s%s\n", depth * 2, " ", depth ? "" : "/", name);
tree = APTERYX_NODE (NULL, g_strdup (name));
node = APTERYX_NODE (tree, g_strdup ("*"));
schema = sch_node_child_first (schema);

if (xml_node_has_content (xml))
{
key_value = (char *) xmlNodeGetContent (xml);
node = APTERYX_NODE (tree, g_strdup (key_value));
if (g_strcmp0 (new_op, "delete") == 0 || g_strcmp0 (new_op, "remove") == 0 ||
g_strcmp0 (new_op, "none") == 0)
{
new_xpath = g_strdup_printf ("%s/%s", old_xpath, key_value);
}
else
{
new_xpath = g_strdup_printf ("%s/%s/%s", old_xpath, key_value, key_value);
node = APTERYX_NODE (node, g_strdup (key_value));
}
g_free (key_value);
g_free (old_xpath);
ret_tree = true;
}
else
{
node = APTERYX_NODE (tree, g_strdup ("*"));
}

if (rschema)
*rschema = schema;
}
Expand Down

0 comments on commit 5ac5359

Please sign in to comment.