@@ -53,6 +53,7 @@ void pyly_cstr_array_free(char **list, size_t nlist)
5353typedef struct {
5454 const struct ly_ctx * ctx ;
5555 const char * base_path ;
56+ int include_children ;
5657 pyly_string_list_t * res ;
5758} pyly_dfs_data_t ;
5859
@@ -208,7 +209,8 @@ static LY_ERR pyly_backlinks_find_leafref_nodes_clb(struct lysc_node *node, void
208209
209210/*! Search the entire loaded schema for any nodes that contain a leafref and
210211 * record the path. If a base_path is specified, only leafrefs that point to
211- * the specified path will be recorded.
212+ * the specified path will be recorded, if include_children is 1, then children
213+ * of the specified path are also included.
212214 *
213215 * This function is used in replacement for the concept of backlink references
214216 * that were part of libyang v1 but were subsequently removed. This is
@@ -221,14 +223,17 @@ static LY_ERR pyly_backlinks_find_leafref_nodes_clb(struct lysc_node *node, void
221223 * the leafref is pointing as part of building the cache. It is expected most
222224 * users will not need the cache and will simply pass in the base_path as needed.
223225 *
224- * \param[in] ctx Initialized context with loaded schema
225- * \param[in] base_path Optional base node path to restrict output.
226- * \param[out] out Pointer passed by reference that will hold a C array
227- * of c strings representing the paths for any leaf
228- * references.
226+ * \param[in] ctx Initialized context with loaded schema
227+ * \param[in] base_path Optional base node path to restrict output.
228+ * \param[in] include_children Whether or not to include children of the
229+ * specified base path or if the path is an
230+ * explicit reference.
231+ * \param[out] out Pointer passed by reference that will hold a C
232+ * array of c strings representing the paths for
233+ * any leaf references.
229234 * \return number of results, or 0 if none.
230235 */
231- size_t pyly_backlinks_find_leafref_nodes (const struct ly_ctx * ctx , const char * base_path , char * * * out )
236+ size_t pyly_backlinks_find_leafref_nodes (const struct ly_ctx * ctx , const char * base_path , int include_children , char * * * out )
232237{
233238 pyly_string_list_t res ;
234239 uint32_t module_idx = 0 ;
@@ -242,7 +247,7 @@ size_t pyly_backlinks_find_leafref_nodes(const struct ly_ctx *ctx, const char *b
242247
243248 /* Iterate across all loaded modules */
244249 for (module_idx = 0 ; (module = ly_ctx_get_module_iter (ctx , & module_idx )) != NULL ; ) {
245- pyly_dfs_data_t data = { ctx , base_path , & res };
250+ pyly_dfs_data_t data = { ctx , base_path , include_children , & res };
246251
247252 lysc_module_dfs_full (module , pyly_backlinks_find_leafref_nodes_clb , & data );
248253 /* Ignore error */
0 commit comments