@@ -1406,77 +1406,6 @@ lyplg_ext_schema_mount_create_context(const struct lysc_ext_instance *ext, const
14061406 return rc ;
14071407}
14081408
1409- static void
1410- schema_mount_spriter_tree_free (void * priv )
1411- {
1412- struct sprinter_tree_priv * st_priv ;
1413-
1414- st_priv = priv ;
1415- ly_set_free (st_priv -> refs , NULL );
1416- ly_ctx_destroy (st_priv -> ext_ctx );
1417- free (st_priv );
1418- }
1419-
1420- static LY_ERR
1421- schema_mount_sprinter_tree_cnode_override_mounted (const struct lysc_node * node , const void * UNUSED (plugin_priv ),
1422- ly_bool * UNUSED (skip ), const char * * UNUSED (flags ), const char * * add_opts )
1423- {
1424- if (!node -> parent ) {
1425- * add_opts = "/" ;
1426- }
1427-
1428- return LY_SUCCESS ;
1429- }
1430-
1431- static LY_ERR
1432- schema_mount_sprinter_tree_pnode_override_mounted (const struct lysp_node * node , const void * UNUSED (plugin_priv ),
1433- ly_bool * UNUSED (skip ), const char * * UNUSED (flags ), const char * * add_opts )
1434- {
1435- if (!node -> parent ) {
1436- * add_opts = "/" ;
1437- }
1438-
1439- return LY_SUCCESS ;
1440- }
1441-
1442- static LY_ERR
1443- schema_mount_sprinter_tree_node_override_parent_refs (const struct lysc_node * node , const void * plugin_priv ,
1444- ly_bool * skip , const char * * UNUSED (flags ), const char * * add_opts )
1445- {
1446- uint32_t i ;
1447- const struct ly_set * refs ;
1448- const struct lysc_module * mod ;
1449- struct lysc_node * ref , * iter ;
1450-
1451- refs = ((struct sprinter_tree_priv * )plugin_priv )-> refs ;
1452- mod = node -> module -> compiled ;
1453-
1454- /* Assume the @p node will be skipped. */
1455- * skip = 1 ;
1456- for (i = 0 ; (i < refs -> count ) && * skip ; i ++ ) {
1457- ref = refs -> snodes [i ];
1458- if (ref -> module -> compiled != mod ) {
1459- /* parent-reference points to different module */
1460- continue ;
1461- }
1462-
1463- for (iter = ref ; iter ; iter = iter -> parent ) {
1464- if (iter == node ) {
1465- /* @p node is not skipped because it is parent-rererence node or his parent */
1466- * skip = 0 ;
1467- break ;
1468- }
1469- }
1470- }
1471-
1472- if (!* skip && !node -> parent ) {
1473- /* top-node has additional opts */
1474- * add_opts = "@" ;
1475- }
1476-
1477- return LY_SUCCESS ;
1478- }
1479-
14801409/**
14811410 * @brief Schema mount schema parsed tree printer.
14821411 *
@@ -1499,118 +1428,14 @@ schema_mount_sprinter_ptree(struct lysp_ext_instance *UNUSED(ext), const struct
14991428 * Implementation of ::lyplg_ext_sprinter_ctree_clb callback set as lyext_plugin::printer_ctree.
15001429 */
15011430static LY_ERR
1502- schema_mount_sprinter_ctree (struct lysc_ext_instance * ext , const struct lyspr_tree_ctx * ctx ,
1431+ schema_mount_sprinter_ctree (struct lysc_ext_instance * UNUSED ( ext ) , const struct lyspr_tree_ctx * ctx ,
15031432 const char * * flags , const char * * UNUSED (add_opts ))
15041433{
1505- LY_ERR rc = LY_SUCCESS ;
1506- struct ly_ctx * ext_ctx = NULL ;
1507- const struct lys_module * mod ;
1508- struct ly_set * refs = NULL ;
1509- struct lysc_node * tree1 , * tree2 ;
1510- uint32_t i , j ;
1511- ly_bool from_parent_ref , is_first ;
1512- struct sprinter_tree_priv * st_priv ;
1513-
15141434 if (!ctx ) {
15151435 * flags = "mp" ;
1516- return LY_SUCCESS ;
1517- }
1518-
1519- if (lyplg_ext_schema_mount_create_context (ext , NULL , & ext_ctx )) {
1520- /* Void mount point */
1521- return LY_SUCCESS ;
1522- }
1523-
1524- rc = lyplg_ext_schema_mount_get_parent_ref (ext , NULL , & refs );
1525- LY_CHECK_GOTO (rc , cleanup );
1526-
1527- /* build new list of modules to print. This list will omit internal
1528- * modules, modules with no nodes (e.g., iana-if-types) and modules
1529- * that were loaded as the result of a parent-reference.
1530- */
1531- i = ly_ctx_internal_modules_count (ext_ctx );
1532- while ((mod = ly_ctx_get_module_iter (ext_ctx , & i ))) {
1533- from_parent_ref = 0 ;
1534-
1535- for (j = 0 ; refs && j < refs -> count ; j ++ ) {
1536- if (!strcmp (mod -> ns , refs -> snodes [j ]-> module -> ns )) {
1537- from_parent_ref = 1 ;
1538- break ;
1539- }
1540- }
1541- if (from_parent_ref ) {
1542- /* Modules loaded as the result of a parent-reference are added later. */
1543- continue ;
1544- }
1545-
1546- /* Add data nodes, rpcs and notifications. */
1547- if ((ext_ctx -> opts & LY_CTX_SET_PRIV_PARSED ) && mod -> compiled ) {
1548- /* For compiled module. */
1549- rc = lyplg_ext_sprinter_ctree_add_nodes (ctx , mod -> compiled -> data ,
1550- schema_mount_sprinter_tree_cnode_override_mounted );
1551- LY_CHECK_GOTO (rc , cleanup );
1552- if (mod -> compiled -> rpcs ) {
1553- rc = lyplg_ext_sprinter_ctree_add_nodes (ctx , & mod -> compiled -> rpcs -> node ,
1554- schema_mount_sprinter_tree_cnode_override_mounted );
1555- }
1556- LY_CHECK_GOTO (rc , cleanup );
1557- if (mod -> compiled -> notifs ) {
1558- rc = lyplg_ext_sprinter_ctree_add_nodes (ctx , & mod -> compiled -> notifs -> node ,
1559- schema_mount_sprinter_tree_cnode_override_mounted );
1560- }
1561- LY_CHECK_GOTO (rc , cleanup );
1562- } else {
1563- /* For parsed module. */
1564- rc = lyplg_ext_sprinter_ptree_add_nodes (ctx , mod -> parsed -> data ,
1565- schema_mount_sprinter_tree_pnode_override_mounted );
1566- LY_CHECK_GOTO (rc , cleanup );
1567- if (mod -> parsed -> rpcs ) {
1568- rc = lyplg_ext_sprinter_ptree_add_nodes (ctx , & mod -> parsed -> rpcs -> node ,
1569- schema_mount_sprinter_tree_pnode_override_mounted );
1570- }
1571- LY_CHECK_GOTO (rc , cleanup );
1572- if (mod -> parsed -> notifs ) {
1573- rc = lyplg_ext_sprinter_ptree_add_nodes (ctx , & mod -> parsed -> notifs -> node ,
1574- schema_mount_sprinter_tree_pnode_override_mounted );
1575- }
1576- LY_CHECK_GOTO (rc , cleanup );
1577- }
1578- }
1579-
1580- /* Add modules loaded as the result of a parent-reference. */
1581- for (i = 0 ; refs && (i < refs -> count ); i ++ ) {
1582- tree1 = refs -> snodes [i ]-> module -> compiled -> data ;
1583-
1584- /* Add data nodes from the module only once. */
1585- is_first = 1 ;
1586- for (j = 0 ; j < i ; j ++ ) {
1587- tree2 = refs -> snodes [j ]-> module -> compiled -> data ;
1588- if (tree1 == tree2 ) {
1589- is_first = 0 ;
1590- break ;
1591- }
1592- }
1593- if (is_first ) {
1594- /* Add all data nodes but unavailable nodes are skipped in the callback. */
1595- rc = lyplg_ext_sprinter_ctree_add_nodes (ctx , tree1 , schema_mount_sprinter_tree_node_override_parent_refs );
1596- LY_CHECK_GOTO (rc , cleanup );
1597- }
15981436 }
15991437
1600- /* add private plugin data */
1601- st_priv = calloc (1 , sizeof (* st_priv ));
1602- LY_CHECK_ERR_GOTO (!st_priv , rc = LY_EMEM , cleanup );
1603- st_priv -> ext_ctx = ext_ctx ;
1604- st_priv -> refs = refs ;
1605- rc = lyplg_ext_sprinter_tree_set_priv (ctx , st_priv , schema_mount_spriter_tree_free );
1606-
1607- cleanup :
1608- if (rc ) {
1609- ly_set_free (refs , NULL );
1610- ly_ctx_destroy (ext_ctx );
1611- }
1612-
1613- return rc ;
1438+ return LY_SUCCESS ;
16141439}
16151440
16161441static int
0 commit comments