2 Commits b7a0b28926 ... 6cb86adf0d

Author SHA1 Message Date
  Serj Kalichev 6cb86adf0d Fix node_exists() 8 months ago
  Serj Kalichev 251fbad043 pline_node_exists() refactoring 8 months ago
1 changed files with 2 additions and 65 deletions
  1. 2 65
      src/pline.c

+ 2 - 65
src/pline.c

@@ -1311,31 +1311,6 @@ static void pline_print_type_help(const struct lysc_node *node,
 }
 }
 
 
 
 
-/*
-static bool_t pline_node_exists(sr_session_ctx_t* sess, const char *xpath)
-{
-	sr_val_t *vals = NULL;
-	size_t val_num = 0;
-	bool_t found = BOOL_FALSE;
-	size_t i = 0;
-
-	if (!xpath)
-		return BOOL_FALSE;
-	sr_get_items(sess, xpath, 0, 0, &vals, &val_num);
-	for (i = 0; i < val_num; i++) {
-		// Engine can find defaults for entries but not entries themself
-		if (!vals[i].dflt) {
-			found = BOOL_TRUE;
-			break;
-		}
-	}
-	sr_free_values(vals, val_num);
-
-	return found;
-}
-*/
-
-
 static bool_t pline_find_node_within_tree(const struct lyd_node *nodes_list,
 static bool_t pline_find_node_within_tree(const struct lyd_node *nodes_list,
 	const struct lysc_node *node)
 	const struct lysc_node *node)
 {
 {
@@ -1348,18 +1323,15 @@ static bool_t pline_find_node_within_tree(const struct lyd_node *nodes_list,
 		const char *default_value = NULL;
 		const char *default_value = NULL;
 		char *value = NULL;
 		char *value = NULL;
 
 
-syslog(LOG_ERR, "iter: %s, node: %s", iter->schema->name, node->name);
 		if (iter->schema != node) {
 		if (iter->schema != node) {
-syslog(LOG_ERR, "iter != node");
-			if (pline_find_node_within_tree(lyd_child(nodes_list),
+			if (pline_find_node_within_tree(lyd_child(iter),
 				node))
 				node))
 				return BOOL_TRUE;
 				return BOOL_TRUE;
 			continue;
 			continue;
 		}
 		}
 		if (iter->flags & LYD_DEFAULT) {
 		if (iter->flags & LYD_DEFAULT) {
-syslog(LOG_ERR, "default");
 			continue;
 			continue;
-}
+		}
 		default_value = klysc_node_ext_default(iter->schema);
 		default_value = klysc_node_ext_default(iter->schema);
 		value = klyd_node_value(iter);
 		value = klyd_node_value(iter);
 		// Don't show "default" keys with default values
 		// Don't show "default" keys with default values
@@ -1383,7 +1355,6 @@ static bool_t pline_node_exists(sr_session_ctx_t* sess, const char *xpath,
 
 
 	if (!xpath)
 	if (!xpath)
 		return BOOL_FALSE;
 		return BOOL_FALSE;
-syslog(LOG_ERR, "xpath = %s", xpath);
 	if (sr_get_data(sess, xpath, 1, 0, 0, &data) != SR_ERR_OK)
 	if (sr_get_data(sess, xpath, 1, 0, 0, &data) != SR_ERR_OK)
 		return BOOL_FALSE;
 		return BOOL_FALSE;
 	if (!data) // Not found
 	if (!data) // Not found
@@ -1394,40 +1365,6 @@ syslog(LOG_ERR, "xpath = %s", xpath);
 	sr_release_data(data);
 	sr_release_data(data);
 
 
 	return found;
 	return found;
-
-
-/*
-	nodes_list = data->tree;
-
-	while (nodes_list && (edepth > 0)) {
-		nodes_list = lyd_child_no_keys(nodes_list);
-		edepth--;
-	}
-
-	if (nodes_list)
-		show_subtree(nodes_list, 0, DIFF_OP_NONE, opts, BOOL_FALSE);
-
-
-
-	sr_val_t *vals = NULL;
-	size_t val_num = 0;
-	size_t i = 0;
-
-	if (!xpath)
-		return BOOL_FALSE;
-	sr_get_items(sess, xpath, 0, 0, &vals, &val_num);
-	for (i = 0; i < val_num; i++) {
-		// Engine can find defaults for entries but not entries themself
-		if (!vals[i].dflt) {
-			found = BOOL_TRUE;
-			break;
-		}
-	}
-	sr_free_values(vals, val_num);
-
-	return found;
-*/
-
 }
 }