|
@@ -171,15 +171,13 @@ static const struct lysc_node *find_child(const struct lysc_node *node,
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-bool_t parse_module(const struct lys_module *module, faux_argv_node_t **arg,
|
|
|
+bool_t pline_parse_module(const struct lys_module *module, faux_argv_node_t **arg,
|
|
|
pline_t *pline)
|
|
|
{
|
|
|
const struct lysc_node *node = NULL;
|
|
|
char *rollback_xpath = NULL;
|
|
|
+
|
|
|
+
|
|
|
bool_t rollback = BOOL_FALSE;
|
|
|
|
|
|
do {
|
|
@@ -193,9 +191,9 @@ bool_t parse_module(const struct lys_module *module, faux_argv_node_t **arg,
|
|
|
char *tmp = NULL;
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- if (node->nodetype & LYS_LEAF) {
|
|
|
+ if (node->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
|
|
|
faux_str_free(rollback_xpath);
|
|
|
rollback_xpath = faux_str_dup(pexpr->xpath);
|
|
|
}
|
|
@@ -205,36 +203,30 @@ bool_t parse_module(const struct lys_module *module, faux_argv_node_t **arg,
|
|
|
node->module->name, node->name);
|
|
|
faux_str_cat(&pexpr->xpath, tmp);
|
|
|
faux_str_free(tmp);
|
|
|
- printf("%s\n", pexpr->xpath);
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
pexpr->active = BOOL_TRUE;
|
|
|
}
|
|
|
|
|
|
-printf("for str = %s\n", str);
|
|
|
-
|
|
|
if (!str)
|
|
|
break;
|
|
|
|
|
|
|
|
|
if (!node) {
|
|
|
-printf("Module\n");
|
|
|
node = find_child(module->compiled->data, str);
|
|
|
if (!node)
|
|
|
return BOOL_FALSE;
|
|
|
-
|
|
|
|
|
|
|
|
|
} else if (node->nodetype & LYS_CONTAINER) {
|
|
|
-printf("Container\n");
|
|
|
node = find_child(lysc_node_child(node), str);
|
|
|
|
|
|
|
|
|
} else if (node->nodetype & LYS_LIST) {
|
|
|
-printf("List\n");
|
|
|
const struct lysc_node *iter = NULL;
|
|
|
- printf("str = %s\n", str);
|
|
|
+
|
|
|
if (!is_rollback) {
|
|
|
LY_LIST_FOR(lysc_node_child(node), iter) {
|
|
|
char *tmp = NULL;
|
|
@@ -249,10 +241,8 @@ printf("List\n");
|
|
|
leaf->name, str);
|
|
|
faux_str_cat(&pexpr->xpath, tmp);
|
|
|
faux_str_free(tmp);
|
|
|
- printf("%s\n", pexpr->xpath);
|
|
|
faux_argv_each(arg);
|
|
|
str = (const char *)faux_argv_current(*arg);
|
|
|
-printf("list str = %s\n", str);
|
|
|
if (!str)
|
|
|
break;
|
|
|
}
|
|
@@ -260,18 +250,32 @@ printf("list str = %s\n", str);
|
|
|
break;
|
|
|
}
|
|
|
node = find_child(lysc_node_child(node), str);
|
|
|
-printf("list next node = %s\n", node ? node->name : "NULL");
|
|
|
|
|
|
|
|
|
} else if (node->nodetype & LYS_LEAF) {
|
|
|
-printf("Leaf\n");
|
|
|
struct lysc_node_leaf *leaf =
|
|
|
(struct lysc_node_leaf *)node;
|
|
|
pexpr_t *new = NULL;
|
|
|
- if (leaf->type->basetype != LY_TYPE_EMPTY) {
|
|
|
+
|
|
|
+ if (leaf->type->basetype != LY_TYPE_EMPTY)
|
|
|
pexpr->value = faux_str_dup(str);
|
|
|
-printf("value=%s\n", pexpr->value);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ node = node->parent;
|
|
|
+ new = pexpr_new();
|
|
|
+ new->xpath = faux_str_dup(rollback_xpath);
|
|
|
+ faux_list_add(pline->exprs, new);
|
|
|
+ rollback = BOOL_TRUE;
|
|
|
+
|
|
|
+
|
|
|
+ } else if (node->nodetype & LYS_LEAFLIST) {
|
|
|
+ pexpr_t *new = NULL;
|
|
|
+ char *tmp = NULL;
|
|
|
+
|
|
|
+ tmp = faux_str_sprintf("[.='%s']", str);
|
|
|
+ faux_str_cat(&pexpr->xpath, tmp);
|
|
|
+ faux_str_free(tmp);
|
|
|
+
|
|
|
|
|
|
|
|
|
node = node->parent;
|
|
@@ -290,24 +294,6 @@ printf("value=%s\n", pexpr->value);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-bool_t parse_tree(const struct lysc_node *tree, faux_argv_node_t **arg,
|
|
|
- pline_t *pline)
|
|
|
-{
|
|
|
- const struct lysc_node *node = NULL;
|
|
|
- const char *str = (const char *)faux_argv_current(*arg);
|
|
|
-
|
|
|
- node = find_child(tree, str);
|
|
|
- if (node) {
|
|
|
- parse_node(node, arg, pline);
|
|
|
- return BOOL_TRUE;
|
|
|
- }
|
|
|
-
|
|
|
- return BOOL_FALSE;
|
|
|
-}
|
|
|
-*/
|
|
|
-
|
|
|
-
|
|
|
pline_t *pline_parse(const struct ly_ctx *ctx, faux_argv_t *argv, uint32_t flags)
|
|
|
{
|
|
|
struct lys_module *module = NULL;
|
|
@@ -330,7 +316,7 @@ pline_t *pline_parse(const struct ly_ctx *ctx, faux_argv_t *argv, uint32_t flags
|
|
|
continue;
|
|
|
if (!module->compiled->data)
|
|
|
continue;
|
|
|
- if (parse_module(module, &arg, pline))
|
|
|
+ if (pline_parse_module(module, &arg, pline))
|
|
|
break;
|
|
|
}
|
|
|
|