Skip to content

Commit 220f055

Browse files
committed
structure REFATCOR minor improvements
1 parent 1466280 commit 220f055

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/plugins_exts/structure.c

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ structure_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, s
260260
}
261261

262262
/**
263-
* @brief INFO printer
263+
* @brief Structure schema info printer.
264264
*
265265
* Implementation of ::lyplg_ext_sprinter_info_clb set as ::lyext_plugin::printer_info
266266
*/
@@ -430,6 +430,11 @@ structure_sprinter_cnode(const struct lysc_node *UNUSED(node), const void *UNUSE
430430
return LY_SUCCESS;
431431
}
432432

433+
/**
434+
* @brief Structure schema compiled tree printer.
435+
*
436+
* Implementation of ::lyplg_ext_sprinter_ctree_clb callback set as lyext_plugin::printer_ctree.
437+
*/
433438
static LY_ERR
434439
structure_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
435440
const char **UNUSED(flags), const char **UNUSED(add_opts))
@@ -440,6 +445,11 @@ structure_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_
440445
return rc;
441446
}
442447

448+
/**
449+
* @brief Structure schema parsed tree printer.
450+
*
451+
* Implementation of ::lyplg_ext_sprinter_ptree_clb callback set as lyext_plugin::printer_ptree.
452+
*/
443453
static LY_ERR
444454
structure_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
445455
const char **UNUSED(flags), const char **UNUSED(add_opts))
@@ -450,6 +460,11 @@ structure_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_tree_
450460
return rc;
451461
}
452462

463+
/**
464+
* @brief Augment structure schema parsed tree printer.
465+
*
466+
* Implementation of ::lyplg_ext_sprinter_ptree_clb callback set as lyext_plugin::printer_ptree.
467+
*/
453468
static LY_ERR
454469
structure_aug_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
455470
const char **UNUSED(flags), const char **UNUSED(add_opts))
@@ -465,9 +480,14 @@ structure_aug_sprinter_ptree(struct lysp_ext_instance *ext, const struct lyspr_t
465480
return rc;
466481
}
467482

483+
/**
484+
* @brief Augment structure schema compiled tree printer.
485+
*
486+
* Implementation of ::lyplg_ext_sprinter_ctree_clb callback set as lyext_plugin::printer_ctree.
487+
*/
468488
static LY_ERR
469-
structure_aug_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx,
470-
const char **flags, const char **add_opts)
489+
structure_aug_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx, const char **flags,
490+
const char **add_opts)
471491
{
472492
LY_ERR rc = LY_SUCCESS;
473493

@@ -476,18 +496,17 @@ structure_aug_sprinter_ctree(struct lysc_ext_instance *ext, const struct lyspr_t
476496

477497
assert(ctx);
478498

499+
/* find the parsed ext structure */
479500
parsed_ext = ext->module->parsed->exts;
480501
LY_ARRAY_FOR(parsed_ext, i) {
481-
if (strcmp(parsed_ext[i].name, "sx:augment-structure")) {
482-
continue;
483-
} else if (strcmp(parsed_ext[i].argument, ext->argument)) {
484-
continue;
502+
if (!strcmp(parsed_ext[i].name, "sx:augment-structure") && !strcmp(parsed_ext[i].argument, ext->argument)) {
503+
break;
485504
}
486-
487-
rc = structure_aug_sprinter_ptree(parsed_ext, ctx, flags, add_opts);
488-
break;
489505
}
506+
assert(i < LY_ARRAY_COUNT(parsed_ext));
490507

508+
/* for augments print the parsed tree */
509+
rc = structure_aug_sprinter_ptree(parsed_ext, ctx, flags, add_opts);
491510
return rc;
492511
}
493512

0 commit comments

Comments
 (0)