Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame^] | 1 | /** |
| 2 | * @file printer_yang.c |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief YANG printer |
| 5 | * |
| 6 | * Copyright (c) 2015 - 2019 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * https://opensource.org/licenses/BSD-3-Clause |
| 13 | */ |
| 14 | |
| 15 | #include "common.h" |
| 16 | |
| 17 | #include "printer_internal.h" |
| 18 | #include "tree_schema.h" |
| 19 | #include "tree_schema_internal.h" |
| 20 | |
| 21 | #define LEVEL ctx->level |
| 22 | #define INDENT (LEVEL)*2,"" |
| 23 | |
| 24 | struct ypr_ctx { |
| 25 | struct lyout *out; |
| 26 | unsigned int level; |
| 27 | const struct lys_module *module; |
| 28 | }; |
| 29 | |
| 30 | static void |
| 31 | ypr_encode(struct lyout *out, const char *text, int len) |
| 32 | { |
| 33 | int i, start_len; |
| 34 | const char *start; |
| 35 | char special = 0; |
| 36 | |
| 37 | if (!len) { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | if (len < 0) { |
| 42 | len = strlen(text); |
| 43 | } |
| 44 | |
| 45 | start = text; |
| 46 | start_len = 0; |
| 47 | for (i = 0; i < len; ++i) { |
| 48 | switch (text[i]) { |
| 49 | case '\n': |
| 50 | case '\t': |
| 51 | case '\"': |
| 52 | case '\\': |
| 53 | special = text[i]; |
| 54 | break; |
| 55 | default: |
| 56 | ++start_len; |
| 57 | break; |
| 58 | } |
| 59 | |
| 60 | if (special) { |
| 61 | ly_write(out, start, start_len); |
| 62 | switch (special) { |
| 63 | case '\n': |
| 64 | ly_write(out, "\\n", 2); |
| 65 | break; |
| 66 | case '\t': |
| 67 | ly_write(out, "\\t", 2); |
| 68 | break; |
| 69 | case '\"': |
| 70 | ly_write(out, "\\\"", 2); |
| 71 | break; |
| 72 | case '\\': |
| 73 | ly_write(out, "\\\\", 2); |
| 74 | break; |
| 75 | } |
| 76 | |
| 77 | start += start_len + 1; |
| 78 | start_len = 0; |
| 79 | |
| 80 | special = 0; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | ly_write(out, start, start_len); |
| 85 | } |
| 86 | |
| 87 | static void |
| 88 | ypr_open(struct lyout *out, int *flag) |
| 89 | { |
| 90 | if (flag && !*flag) { |
| 91 | *flag = 1; |
| 92 | ly_print(out, " {\n"); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | static void |
| 97 | ypr_close(struct ypr_ctx *ctx, int flag) |
| 98 | { |
| 99 | if (flag) { |
| 100 | ly_print(ctx->out, "%*s}\n", INDENT); |
| 101 | } else { |
| 102 | ly_print(ctx->out, ";\n"); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | static void |
| 107 | ypr_text(struct ypr_ctx *ctx, const char *name, const char *text, int singleline, int closed) |
| 108 | { |
| 109 | const char *s, *t; |
| 110 | |
| 111 | if (singleline) { |
| 112 | ly_print(ctx->out, "%*s%s \"", INDENT, name); |
| 113 | } else { |
| 114 | ly_print(ctx->out, "%*s%s\n", INDENT, name); |
| 115 | LEVEL++; |
| 116 | |
| 117 | ly_print(ctx->out, "%*s\"", INDENT); |
| 118 | } |
| 119 | t = text; |
| 120 | while ((s = strchr(t, '\n'))) { |
| 121 | ypr_encode(ctx->out, t, s - t); |
| 122 | ly_print(ctx->out, "\n"); |
| 123 | t = s + 1; |
| 124 | if (*t != '\n') { |
| 125 | ly_print(ctx->out, "%*s ", INDENT); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | ypr_encode(ctx->out, t, strlen(t)); |
| 130 | if (closed) { |
| 131 | ly_print(ctx->out, "\";\n"); |
| 132 | } else { |
| 133 | ly_print(ctx->out, "\""); |
| 134 | } |
| 135 | if (!singleline) { |
| 136 | LEVEL--; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | static void |
| 141 | ypr_parsed_stmt(struct ypr_ctx *ctx, struct lysp_stmt *stmt) |
| 142 | { |
| 143 | struct lysp_stmt *childstmt; |
| 144 | const char *s, *t; |
| 145 | |
| 146 | if (stmt->arg) { |
| 147 | if (stmt->flags) { |
| 148 | ly_print(ctx->out, "%*s%s\n", INDENT, stmt->stmt); |
| 149 | LEVEL++; |
| 150 | ly_print(ctx->out, "%*s%c", INDENT, (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\''); |
| 151 | t = stmt->arg; |
| 152 | while ((s = strchr(t, '\n'))) { |
| 153 | ypr_encode(ctx->out, t, s - t); |
| 154 | ly_print(ctx->out, "\n"); |
| 155 | t = s + 1; |
| 156 | if (*t != '\n') { |
| 157 | ly_print(ctx->out, "%*s ", INDENT); |
| 158 | } |
| 159 | } |
| 160 | LEVEL--; |
| 161 | ypr_encode(ctx->out, t, strlen(t)); |
| 162 | ly_print(ctx->out, "%c%s", (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\'', stmt->child ? " {\n" : ";\n"); |
| 163 | } else { |
| 164 | ly_print(ctx->out, "%*s%s %s%s", INDENT, stmt->stmt, stmt->arg, stmt->child ? " {\n" : ";\n"); |
| 165 | } |
| 166 | } else { |
| 167 | ly_print(ctx->out, "%*s%s%s", INDENT, stmt->stmt, stmt->child ? " {\n" : ";\n"); |
| 168 | } |
| 169 | |
| 170 | if (stmt->child) { |
| 171 | LEVEL++; |
| 172 | LY_LIST_FOR(stmt->child, childstmt) { |
| 173 | ypr_parsed_stmt(ctx, childstmt); |
| 174 | } |
| 175 | LEVEL--; |
| 176 | ly_print(ctx->out, "%*s}\n", INDENT); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * @param[in] count Number of extensions to print, 0 to print them all. |
| 182 | */ |
| 183 | static void |
| 184 | ypr_parsed_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, |
| 185 | struct lysp_ext_instance *ext, int *flag, unsigned int count) |
| 186 | { |
| 187 | unsigned int u; |
| 188 | struct lysp_stmt *stmt; |
| 189 | |
| 190 | if (!count && ext) { |
| 191 | count = LY_ARRAY_SIZE(ext); |
| 192 | } |
| 193 | LY_ARRAY_FOR(ext, u) { |
| 194 | if (!count) { |
| 195 | break; |
| 196 | } |
| 197 | if (ext->insubstmt == substmt && ext->insubstmt_index == substmt_index) { |
| 198 | ypr_open(ctx->out, flag); |
| 199 | if (ext[u].argument) { |
| 200 | ly_print(ctx->out, "%*s%s %s%s", INDENT, ext[u].name, ext[u].argument, ext[u].child ? " {\n" : ";\n"); |
| 201 | } else { |
| 202 | ly_print(ctx->out, "%*s%s%s", INDENT, ext[u].name, ext[u].child ? " {\n" : ";\n"); |
| 203 | } |
| 204 | |
| 205 | if (ext[u].child) { |
| 206 | LEVEL++; |
| 207 | LY_LIST_FOR(ext[u].child, stmt) { |
| 208 | ypr_parsed_stmt(ctx, stmt); |
| 209 | } |
| 210 | LEVEL--; |
| 211 | ly_print(ctx->out, "%*s}\n", INDENT); |
| 212 | } |
| 213 | } |
| 214 | count--; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | static void |
| 219 | ypr_parsed_substmt(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, const char *text, struct lysp_ext_instance *ext) |
| 220 | { |
| 221 | unsigned int u; |
| 222 | int extflag = 0; |
| 223 | |
| 224 | if (!text) { |
| 225 | /* nothing to print */ |
| 226 | return; |
| 227 | } |
| 228 | |
| 229 | if (ext_substmt_info[substmt].flags & SUBST_FLAG_ID) { |
| 230 | ly_print(ctx->out, "%*s%s %s", INDENT, ext_substmt_info[substmt].name, text); |
| 231 | } else { |
| 232 | ypr_text(ctx, ext_substmt_info[substmt].name, text, |
| 233 | (ext_substmt_info[substmt].flags & SUBST_FLAG_YIN) ? 0 : 1, 0); |
| 234 | } |
| 235 | |
| 236 | LEVEL++; |
| 237 | LY_ARRAY_FOR(ext, u) { |
| 238 | if (ext[u].insubstmt != substmt || ext[u].insubstmt_index != substmt_index) { |
| 239 | continue; |
| 240 | } |
| 241 | ypr_parsed_extension_instances(ctx, substmt, substmt_index, &ext[u], &extflag, 1); |
| 242 | } |
| 243 | LEVEL--; |
| 244 | ypr_close(ctx, extflag); |
| 245 | } |
| 246 | |
| 247 | static void |
| 248 | ypr_parsed_unsigned(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, struct lysp_ext_instance *exts, |
| 249 | unsigned int attr_value, int *flag) |
| 250 | { |
| 251 | char *str; |
| 252 | |
| 253 | if (asprintf(&str, "%u", attr_value) == -1) { |
| 254 | LOGMEM(ctx->module->ctx); |
| 255 | return; |
| 256 | } |
| 257 | ypr_open(ctx->out, flag); |
| 258 | ypr_parsed_substmt(ctx, substmt, substmt_index, str, exts); |
| 259 | free(str); |
| 260 | } |
| 261 | |
| 262 | static void |
| 263 | ypr_parsed_signed(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, struct lysp_ext_instance *exts, |
| 264 | signed int attr_value, int *flag) |
| 265 | { |
| 266 | char *str; |
| 267 | |
| 268 | if (asprintf(&str, "%d", attr_value) == -1) { |
| 269 | LOGMEM(ctx->module->ctx); |
| 270 | return; |
| 271 | } |
| 272 | ypr_open(ctx->out, flag); |
| 273 | ypr_parsed_substmt(ctx, substmt, substmt_index, str, exts); |
| 274 | free(str); |
| 275 | } |
| 276 | |
| 277 | static void |
| 278 | ypr_parsed_revision(struct ypr_ctx *ctx, const struct lysp_revision *rev) |
| 279 | { |
| 280 | if (rev->dsc || rev->ref || rev->exts) { |
| 281 | ly_print(ctx->out, "%*srevision %s {\n", INDENT, rev->date); |
| 282 | LEVEL++; |
| 283 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, rev->exts, NULL, 0); |
| 284 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, rev->dsc, rev->exts); |
| 285 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, rev->ref, rev->exts); |
| 286 | LEVEL--; |
| 287 | ly_print(ctx->out, "%*s}\n", INDENT); |
| 288 | } else { |
| 289 | ly_print(ctx->out, "%*srevision %s;\n", INDENT, rev->date); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | static void |
| 294 | ypr_parsed_mandatory(struct ypr_ctx *ctx, uint16_t flags, struct lysp_ext_instance *exts, int *flag) |
| 295 | { |
| 296 | if (flags & LYS_MAND_MASK) { |
| 297 | ypr_open(ctx->out, flag); |
| 298 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | static void |
| 303 | ypr_parsed_config(struct ypr_ctx *ctx, uint16_t flags, struct lysp_ext_instance *exts, int *flag) |
| 304 | { |
| 305 | if (flags & LYS_CONFIG_MASK) { |
| 306 | ypr_open(ctx->out, flag); |
| 307 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | static void |
| 312 | ypr_parsed_status(struct ypr_ctx *ctx, uint16_t flags, struct lysp_ext_instance *exts, int *flag) |
| 313 | { |
| 314 | const char *status = NULL; |
| 315 | |
| 316 | if (flags & LYS_STATUS_CURR) { |
| 317 | ypr_open(ctx->out, flag); |
| 318 | status = "current"; |
| 319 | } else if (flags & LYS_STATUS_DEPRC) { |
| 320 | ypr_open(ctx->out, flag); |
| 321 | status = "deprecated"; |
| 322 | } else if (flags & LYS_STATUS_OBSLT) { |
| 323 | ypr_open(ctx->out, flag); |
| 324 | status = "obsolete"; |
| 325 | } |
| 326 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_STATUS, 0, status, exts); |
| 327 | } |
| 328 | |
| 329 | static void |
| 330 | ypr_description(struct ypr_ctx *ctx, const char *dsc, struct lysp_ext_instance *exts, int *flag) |
| 331 | { |
| 332 | if (dsc) { |
| 333 | ypr_open(ctx->out, flag); |
| 334 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, dsc, exts); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | static void |
| 339 | ypr_reference(struct ypr_ctx *ctx, const char *ref, struct lysp_ext_instance *exts, int *flag) |
| 340 | { |
| 341 | if (ref) { |
| 342 | ypr_open(ctx->out, flag); |
| 343 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, ref, exts); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | static void |
| 348 | ypr_parsed_iffeatures(struct ypr_ctx *ctx, const char **iff, struct lysp_ext_instance *exts, int *flag) |
| 349 | { |
| 350 | unsigned int u; |
| 351 | int extflag; |
| 352 | |
| 353 | LY_ARRAY_FOR(iff, u) { |
| 354 | ypr_open(ctx->out, flag); |
| 355 | extflag = 0; |
| 356 | |
| 357 | ly_print(ctx->out, "%*sif-feature \"%s\"", INDENT, iff[u]); |
| 358 | |
| 359 | /* extensions */ |
| 360 | LEVEL++; |
| 361 | LY_ARRAY_FOR(exts, u) { |
| 362 | if (exts[u].insubstmt != LYEXT_SUBSTMT_IFFEATURE || exts[u].insubstmt_index != u) { |
| 363 | continue; |
| 364 | } |
| 365 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_IFFEATURE, u, &exts[u], &extflag, 1); |
| 366 | } |
| 367 | LEVEL--; |
| 368 | ypr_close(ctx, extflag); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | static void |
| 373 | ypr_parsed_extension(struct ypr_ctx *ctx, const struct lysp_ext *ext) |
| 374 | { |
| 375 | int flag = 0, flag2 = 0; |
| 376 | unsigned int i; |
| 377 | |
| 378 | ly_print(ctx->out, "%*sextension %s", INDENT, ext->name); |
| 379 | LEVEL++; |
| 380 | |
| 381 | if (ext->exts) { |
| 382 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ext->exts, &flag, 0); |
| 383 | } |
| 384 | |
| 385 | if (ext->argument) { |
| 386 | ypr_open(ctx->out, &flag); |
| 387 | ly_print(ctx->out, "%*sargument %s", INDENT, ext->argument); |
| 388 | if (ext->exts) { |
| 389 | LEVEL++; |
| 390 | i = -1; |
| 391 | while ((i = lysp_ext_instance_iter(ext->exts, i + 1, LYEXT_SUBSTMT_ARGUMENT)) != LY_ARRAY_SIZE(ext->exts)) { |
| 392 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_ARGUMENT, 0, &ext->exts[i], &flag2, 1); |
| 393 | } |
| 394 | LEVEL--; |
| 395 | } |
| 396 | if ((ext->flags & LYS_YINELEM_MASK) || |
| 397 | (ext->exts && lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_SIZE(ext->exts))) { |
| 398 | ypr_open(ctx->out, &flag2); |
| 399 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_YINELEM, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts); |
| 400 | } |
| 401 | ypr_close(ctx, flag2); |
| 402 | } |
| 403 | |
| 404 | ypr_parsed_status(ctx, ext->flags, ext->exts, &flag); |
| 405 | ypr_description(ctx, ext->dsc, ext->exts, &flag); |
| 406 | ypr_reference(ctx, ext->ref, ext->exts, &flag); |
| 407 | |
| 408 | LEVEL--; |
| 409 | ypr_close(ctx, flag); |
| 410 | } |
| 411 | |
| 412 | static void |
| 413 | ypr_parsed_feature(struct ypr_ctx *ctx, const struct lysp_feature *feat) |
| 414 | { |
| 415 | int flag = 0; |
| 416 | |
| 417 | ly_print(ctx->out, "\n%*sfeature %s", INDENT, feat->name); |
| 418 | LEVEL++; |
| 419 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, feat->exts, &flag, 0); |
| 420 | ypr_parsed_iffeatures(ctx, feat->iffeatures, feat->exts, &flag); |
| 421 | ypr_parsed_status(ctx, feat->flags, feat->exts, &flag); |
| 422 | ypr_description(ctx, feat->dsc, feat->exts, &flag); |
| 423 | ypr_reference(ctx, feat->ref, feat->exts, &flag); |
| 424 | LEVEL--; |
| 425 | ypr_close(ctx, flag); |
| 426 | } |
| 427 | |
| 428 | static void |
| 429 | ypr_parsed_identity(struct ypr_ctx *ctx, const struct lysp_ident *ident) |
| 430 | { |
| 431 | int flag = 0; |
| 432 | unsigned int u; |
| 433 | |
| 434 | ly_print(ctx->out, "\n%*sidentity %s", INDENT, ident->name); |
| 435 | LEVEL++; |
| 436 | |
| 437 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ident->exts, &flag, 0); |
| 438 | ypr_parsed_iffeatures(ctx, ident->iffeatures, ident->exts, &flag); |
| 439 | |
| 440 | LY_ARRAY_FOR(ident->bases, u) { |
| 441 | ypr_open(ctx->out, &flag); |
| 442 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_BASE, u, ident->bases[u], ident->exts); |
| 443 | } |
| 444 | |
| 445 | ypr_parsed_status(ctx, ident->flags, ident->exts, &flag); |
| 446 | ypr_description(ctx, ident->dsc, ident->exts, &flag); |
| 447 | ypr_reference(ctx, ident->ref, ident->exts, &flag); |
| 448 | |
| 449 | LEVEL--; |
| 450 | ypr_close(ctx, flag); |
| 451 | } |
| 452 | |
| 453 | static void |
| 454 | ypr_parsed_restr(struct ypr_ctx *ctx, const struct lysp_restr *restr, const char *name, int *flag) |
| 455 | { |
| 456 | int inner_flag = 0; |
| 457 | |
| 458 | if (!restr) { |
| 459 | return; |
| 460 | } |
| 461 | |
| 462 | ypr_open(ctx->out, flag); |
| 463 | ly_print(ctx->out, "%*s%s \"", INDENT, name); |
| 464 | ypr_encode(ctx->out, (restr->arg[0] != 0x15 && restr->arg[0] != 0x06) ? restr->arg : &restr->arg[1], -1); |
| 465 | ly_print(ctx->out, "\""); |
| 466 | |
| 467 | LEVEL++; |
| 468 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, restr->exts, &inner_flag, 0); |
| 469 | if (restr->arg[0] == 0x15) { |
| 470 | /* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */ |
| 471 | ypr_open(ctx->out, &inner_flag); |
| 472 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_MODIFIER, 0, "invert-match", restr->exts); |
| 473 | } |
| 474 | if (restr->emsg) { |
| 475 | ypr_open(ctx->out, &inner_flag); |
| 476 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_ERRMSG, 0, restr->emsg, restr->exts); |
| 477 | } |
| 478 | if (restr->eapptag) { |
| 479 | ypr_open(ctx->out, &inner_flag); |
| 480 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_ERRTAG, 0, restr->eapptag, restr->exts); |
| 481 | } |
| 482 | if (restr->dsc != NULL) { |
| 483 | ypr_open(ctx->out, &inner_flag); |
| 484 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, restr->dsc,restr->exts); |
| 485 | } |
| 486 | if (restr->ref != NULL) { |
| 487 | ypr_open(ctx->out, &inner_flag); |
| 488 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, restr->ref, restr->exts); |
| 489 | } |
| 490 | LEVEL--; |
| 491 | ypr_close(ctx, inner_flag); |
| 492 | } |
| 493 | |
| 494 | static void |
| 495 | ypr_parsed_when(struct ypr_ctx *ctx, struct lysp_when *when, int *flag) |
| 496 | { |
| 497 | int inner_flag = 0; |
| 498 | |
| 499 | if (!when) { |
| 500 | return; |
| 501 | } |
| 502 | ypr_open(ctx->out, flag); |
| 503 | |
| 504 | ly_print(ctx->out, "%*swhen \"", INDENT); |
| 505 | ypr_encode(ctx->out, when->cond, -1); |
| 506 | ly_print(ctx->out, "\""); |
| 507 | |
| 508 | LEVEL++; |
| 509 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, when->exts, &inner_flag, 0); |
| 510 | ypr_description(ctx, when->dsc, when->exts, &inner_flag); |
| 511 | ypr_reference(ctx, when->ref, when->exts, &inner_flag); |
| 512 | LEVEL--; |
| 513 | ypr_close(ctx, inner_flag); |
| 514 | } |
| 515 | |
| 516 | static void |
| 517 | ypr_parsed_enum(struct ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, int *flag) |
| 518 | { |
| 519 | unsigned int u; |
| 520 | int inner_flag; |
| 521 | |
| 522 | LY_ARRAY_FOR(items, u) { |
| 523 | ypr_open(ctx->out, flag); |
| 524 | ly_print(ctx->out, "%*s%s \"", INDENT, type == LY_TYPE_BITS ? "bit" : "enum"); |
| 525 | ypr_encode(ctx->out, items[u].name, -1); |
| 526 | ly_print(ctx->out, "\""); |
| 527 | inner_flag = 0; |
| 528 | LEVEL++; |
| 529 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, items[u].exts, &inner_flag, 0); |
| 530 | ypr_parsed_iffeatures(ctx, items[u].iffeatures, items[u].exts, &inner_flag); |
| 531 | if (items[u].flags & LYS_SET_VALUE) { |
| 532 | if (type == LY_TYPE_BITS) { |
| 533 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_POSITION, 0, items[u].exts, items[u].value, &inner_flag); |
| 534 | } else { /* LY_TYPE_ENUM */ |
| 535 | ypr_parsed_signed(ctx, LYEXT_SUBSTMT_VALUE, 0, items[u].exts, items[u].value, &inner_flag); |
| 536 | } |
| 537 | } |
| 538 | ypr_parsed_status(ctx, items[u].flags, items[u].exts, &inner_flag); |
| 539 | ypr_description(ctx, items[u].dsc, items[u].exts, &inner_flag); |
| 540 | ypr_reference(ctx, items[u].ref, items[u].exts, &inner_flag); |
| 541 | LEVEL--; |
| 542 | ypr_close(ctx, inner_flag); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | static void |
| 547 | ypr_parsed_type(struct ypr_ctx *ctx, const struct lysp_type *type) |
| 548 | { |
| 549 | unsigned int u; |
| 550 | int flag = 0; |
| 551 | |
| 552 | ly_print(ctx->out, "%*stype %s", INDENT, type->name); |
| 553 | LEVEL++; |
| 554 | |
| 555 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, type->exts, &flag, 0); |
| 556 | |
| 557 | ypr_parsed_restr(ctx, type->range, "range", &flag); |
| 558 | ypr_parsed_restr(ctx, type->length, "length", &flag); |
| 559 | LY_ARRAY_FOR(type->patterns, u) { |
| 560 | ypr_parsed_restr(ctx, &type->patterns[u], "pattern", &flag); |
| 561 | } |
| 562 | ypr_parsed_enum(ctx, type->bits, LY_TYPE_BITS, &flag); |
| 563 | ypr_parsed_enum(ctx, type->enums, LY_TYPE_ENUM, &flag); |
| 564 | |
| 565 | if (type->path) { |
| 566 | ypr_open(ctx->out, &flag); |
| 567 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_PATH, 0, type->path, type->exts); |
| 568 | } |
| 569 | if (type->flags & LYS_SET_REQINST) { |
| 570 | ypr_open(ctx->out, &flag); |
| 571 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REQINSTANCE, 0, type->require_instance ? "true" : "false", type->exts); |
| 572 | } |
| 573 | if (type->flags & LYS_SET_FRDIGITS) { |
| 574 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_FRACDIGITS, 0, type->exts, type->fraction_digits, &flag); |
| 575 | } |
| 576 | LY_ARRAY_FOR(type->bases, u) { |
| 577 | ypr_open(ctx->out, &flag); |
| 578 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_BASE, u, type->bases[u], type->exts); |
| 579 | } |
| 580 | LY_ARRAY_FOR(type->types, u) { |
| 581 | ypr_open(ctx->out, &flag); |
| 582 | ypr_parsed_type(ctx, &type->types[u]); |
| 583 | } |
| 584 | |
| 585 | LEVEL--; |
| 586 | ypr_close(ctx, flag); |
| 587 | } |
| 588 | |
| 589 | static void |
| 590 | ypr_parsed_typedef(struct ypr_ctx *ctx, const struct lysp_tpdf *tpdf) |
| 591 | { |
| 592 | ly_print(ctx->out, "\n%*stypedef %s {\n", INDENT, tpdf->name); |
| 593 | LEVEL++; |
| 594 | |
| 595 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, tpdf->exts, NULL, 0); |
| 596 | |
| 597 | ypr_parsed_type(ctx, &tpdf->type); |
| 598 | |
| 599 | if (tpdf->units) { |
| 600 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, tpdf->units, tpdf->exts); |
| 601 | } |
| 602 | if (tpdf->dflt) { |
| 603 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, tpdf->dflt, tpdf->exts); |
| 604 | } |
| 605 | |
| 606 | ypr_parsed_status(ctx, tpdf->flags, tpdf->exts, NULL); |
| 607 | ypr_description(ctx, tpdf->dsc, tpdf->exts, NULL); |
| 608 | ypr_reference(ctx, tpdf->ref, tpdf->exts, NULL); |
| 609 | |
| 610 | LEVEL--; |
| 611 | ly_print(ctx->out, "%*s}\n", INDENT); |
| 612 | } |
| 613 | |
| 614 | static void ypr_parsed_node(struct ypr_ctx *ctx, const struct lysp_node *node); |
| 615 | static void ypr_parsed_action(struct ypr_ctx *ctx, const struct lysp_action *action); |
| 616 | |
| 617 | static void |
| 618 | ypr_parsed_grouping(struct ypr_ctx *ctx, const struct lysp_grp *grp) |
| 619 | { |
| 620 | unsigned int u; |
| 621 | int flag = 0; |
| 622 | struct lysp_node *data; |
| 623 | |
| 624 | ly_print(ctx->out, "\n%*sgrouping %s", INDENT, grp->name); |
| 625 | LEVEL++; |
| 626 | |
| 627 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, grp->exts, &flag, 0); |
| 628 | ypr_parsed_status(ctx, grp->flags, grp->exts, NULL); |
| 629 | ypr_description(ctx, grp->dsc, grp->exts, NULL); |
| 630 | ypr_reference(ctx, grp->ref, grp->exts, NULL); |
| 631 | |
| 632 | LY_ARRAY_FOR(grp->typedefs, u) { |
| 633 | ypr_parsed_typedef(ctx, &grp->typedefs[u]); |
| 634 | } |
| 635 | |
| 636 | LY_ARRAY_FOR(grp->groupings, u) { |
| 637 | ypr_parsed_grouping(ctx, &grp->groupings[u]); |
| 638 | } |
| 639 | |
| 640 | LY_LIST_FOR(grp->data, data) { |
| 641 | ypr_parsed_node(ctx, data); |
| 642 | } |
| 643 | |
| 644 | LY_ARRAY_FOR(grp->actions, u) { |
| 645 | ypr_parsed_action(ctx, &grp->actions[u]); |
| 646 | } |
| 647 | |
| 648 | LEVEL--; |
| 649 | ypr_close(ctx, flag); |
| 650 | } |
| 651 | |
| 652 | static void |
| 653 | ypr_parsed_inout(struct ypr_ctx *ctx, const struct lysp_action_inout *inout, int *flag) |
| 654 | { |
| 655 | unsigned int u; |
| 656 | struct lysp_node *data; |
| 657 | |
| 658 | if (!inout->nodetype) { |
| 659 | /* nodetype not set -> input/output is empty */ |
| 660 | return; |
| 661 | } |
| 662 | ypr_open(ctx->out, flag); |
| 663 | |
| 664 | ly_print(ctx->out, "\n%*s%s {\n", INDENT, (inout->nodetype == LYS_INPUT ? "input" : "output")); |
| 665 | LEVEL++; |
| 666 | |
| 667 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, inout->exts, NULL, 0); |
| 668 | LY_ARRAY_FOR(inout->musts, u) { |
| 669 | ypr_parsed_restr(ctx, &inout->musts[u], "must", NULL); |
| 670 | } |
| 671 | LY_ARRAY_FOR(inout->typedefs, u) { |
| 672 | ypr_parsed_typedef(ctx, &inout->typedefs[u]); |
| 673 | } |
| 674 | LY_ARRAY_FOR(inout->groupings, u) { |
| 675 | ypr_parsed_grouping(ctx, &inout->groupings[u]); |
| 676 | } |
| 677 | |
| 678 | LY_LIST_FOR(inout->data, data) { |
| 679 | ypr_parsed_node(ctx, data); |
| 680 | } |
| 681 | |
| 682 | LEVEL--; |
| 683 | ypr_close(ctx, 1); |
| 684 | } |
| 685 | |
| 686 | static void |
| 687 | ypr_parsed_notification(struct ypr_ctx *ctx, const struct lysp_notif *notif) |
| 688 | { |
| 689 | unsigned int u; |
| 690 | int flag = 0; |
| 691 | struct lysp_node *data; |
| 692 | |
| 693 | ly_print(ctx->out, "%*snotification %s", INDENT, notif->name); |
| 694 | |
| 695 | LEVEL++; |
| 696 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, notif->exts, &flag, 0); |
| 697 | ypr_parsed_iffeatures(ctx, notif->iffeatures, notif->exts, &flag); |
| 698 | |
| 699 | LY_ARRAY_FOR(notif->musts, u) { |
| 700 | ypr_parsed_restr(ctx, ¬if->musts[u], "must", &flag); |
| 701 | } |
| 702 | ypr_parsed_status(ctx, notif->flags, notif->exts, &flag); |
| 703 | ypr_description(ctx, notif->dsc, notif->exts, &flag); |
| 704 | ypr_reference(ctx, notif->ref, notif->exts, &flag); |
| 705 | |
| 706 | LY_ARRAY_FOR(notif->typedefs, u) { |
| 707 | ypr_open(ctx->out, &flag); |
| 708 | ypr_parsed_typedef(ctx, ¬if->typedefs[u]); |
| 709 | } |
| 710 | |
| 711 | LY_ARRAY_FOR(notif->groupings, u) { |
| 712 | ypr_open(ctx->out, &flag); |
| 713 | ypr_parsed_grouping(ctx, ¬if->groupings[u]); |
| 714 | } |
| 715 | |
| 716 | LY_LIST_FOR(notif->data, data) { |
| 717 | ypr_open(ctx->out, &flag); |
| 718 | ypr_parsed_node(ctx, data); |
| 719 | } |
| 720 | |
| 721 | LEVEL--; |
| 722 | ypr_close(ctx, flag); |
| 723 | } |
| 724 | |
| 725 | static void |
| 726 | ypr_parsed_action(struct ypr_ctx *ctx, const struct lysp_action *action) |
| 727 | { |
| 728 | unsigned int u; |
| 729 | int flag = 0; |
| 730 | |
| 731 | ly_print(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name); |
| 732 | |
| 733 | LEVEL++; |
| 734 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, action->exts, &flag, 0); |
| 735 | ypr_parsed_iffeatures(ctx, action->iffeatures, action->exts, &flag); |
| 736 | ypr_parsed_status(ctx, action->flags, action->exts, &flag); |
| 737 | ypr_description(ctx, action->dsc, action->exts, &flag); |
| 738 | ypr_reference(ctx, action->ref, action->exts, &flag); |
| 739 | |
| 740 | LY_ARRAY_FOR(action->typedefs, u) { |
| 741 | ypr_open(ctx->out, &flag); |
| 742 | ypr_parsed_typedef(ctx, &action->typedefs[u]); |
| 743 | } |
| 744 | |
| 745 | LY_ARRAY_FOR(action->groupings, u) { |
| 746 | ypr_open(ctx->out, &flag); |
| 747 | ypr_parsed_grouping(ctx, &action->groupings[u]); |
| 748 | } |
| 749 | |
| 750 | ypr_parsed_inout(ctx, &action->input, &flag); |
| 751 | ypr_parsed_inout(ctx, &action->output, &flag); |
| 752 | |
| 753 | LEVEL--; |
| 754 | ypr_close(ctx, flag); |
| 755 | } |
| 756 | |
| 757 | static void |
| 758 | ypr_parsed_node_common1(struct ypr_ctx *ctx, const struct lysp_node *node, int *flag) |
| 759 | { |
| 760 | ly_print(ctx->out, "\n%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n"); |
| 761 | LEVEL++; |
| 762 | |
| 763 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, node->exts, flag, 0); |
| 764 | ypr_parsed_when(ctx, node->when, flag); |
| 765 | ypr_parsed_iffeatures(ctx, node->iffeatures, node->exts, flag); |
| 766 | } |
| 767 | |
| 768 | static void |
| 769 | ypr_parsed_node_common2(struct ypr_ctx *ctx, const struct lysp_node *node, int *flag) |
| 770 | { |
| 771 | ypr_parsed_config(ctx, node->flags, node->exts, flag); |
| 772 | if (node->nodetype & (LYS_CHOICE | LYS_LEAF | LYS_ANYDATA)) { |
| 773 | ypr_parsed_mandatory(ctx, node->flags, node->exts, flag); |
| 774 | } |
| 775 | ypr_parsed_status(ctx, node->flags, node->exts, flag); |
| 776 | ypr_description(ctx, node->dsc, node->exts, flag); |
| 777 | ypr_reference(ctx, node->ref, node->exts, flag); |
| 778 | |
| 779 | } |
| 780 | |
| 781 | static void |
| 782 | ypr_parsed_container(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 783 | { |
| 784 | unsigned int u; |
| 785 | int flag = 0; |
| 786 | struct lysp_node *child; |
| 787 | struct lysp_node_container *cont = (struct lysp_node_container *)node; |
| 788 | |
| 789 | ypr_parsed_node_common1(ctx, node, &flag); |
| 790 | |
| 791 | LY_ARRAY_FOR(cont->musts, u) { |
| 792 | ypr_parsed_restr(ctx, &cont->musts[u], "must", &flag); |
| 793 | } |
| 794 | if (cont->presence) { |
| 795 | ypr_open(ctx->out, &flag); |
| 796 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, cont->presence, cont->exts); |
| 797 | } |
| 798 | |
| 799 | ypr_parsed_node_common2(ctx, node, &flag); |
| 800 | |
| 801 | LY_ARRAY_FOR(cont->typedefs, u) { |
| 802 | ypr_open(ctx->out, &flag); |
| 803 | ypr_parsed_typedef(ctx, &cont->typedefs[u]); |
| 804 | } |
| 805 | |
| 806 | LY_ARRAY_FOR(cont->groupings, u) { |
| 807 | ypr_open(ctx->out, &flag); |
| 808 | ypr_parsed_grouping(ctx, &cont->groupings[u]); |
| 809 | } |
| 810 | |
| 811 | LY_LIST_FOR(cont->child, child) { |
| 812 | ypr_open(ctx->out, &flag); |
| 813 | ypr_parsed_node(ctx, child); |
| 814 | } |
| 815 | |
| 816 | LY_ARRAY_FOR(cont->actions, u) { |
| 817 | ypr_open(ctx->out, &flag); |
| 818 | ypr_parsed_action(ctx, &cont->actions[u]); |
| 819 | } |
| 820 | |
| 821 | LY_ARRAY_FOR(cont->notifs, u) { |
| 822 | ypr_open(ctx->out, &flag); |
| 823 | ypr_parsed_notification(ctx, &cont->notifs[u]); |
| 824 | } |
| 825 | |
| 826 | LEVEL--; |
| 827 | ypr_close(ctx, flag); |
| 828 | } |
| 829 | |
| 830 | static void |
| 831 | ypr_parsed_choice(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 832 | { |
| 833 | int flag = 0; |
| 834 | struct lysp_node *child; |
| 835 | struct lysp_node_choice *choice = (struct lysp_node_choice *)node; |
| 836 | |
| 837 | ypr_parsed_node_common1(ctx, node, &flag); |
| 838 | |
| 839 | if (choice->dflt) { |
| 840 | ypr_open(ctx->out, &flag); |
| 841 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, choice->dflt, choice->exts); |
| 842 | } |
| 843 | |
| 844 | ypr_parsed_node_common2(ctx, node, &flag); |
| 845 | |
| 846 | LY_LIST_FOR(choice->child, child) { |
| 847 | ypr_open(ctx->out, &flag); |
| 848 | ypr_parsed_node(ctx, child); |
| 849 | } |
| 850 | |
| 851 | LEVEL--; |
| 852 | ypr_close(ctx, flag); |
| 853 | } |
| 854 | |
| 855 | static void |
| 856 | ypr_parsed_leaf(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 857 | { |
| 858 | unsigned int u; |
| 859 | struct lysp_node_leaf *leaf = (struct lysp_node_leaf *)node; |
| 860 | |
| 861 | ypr_parsed_node_common1(ctx, node, NULL); |
| 862 | |
| 863 | ypr_parsed_type(ctx, &leaf->type); |
| 864 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, leaf->units, leaf->exts); |
| 865 | LY_ARRAY_FOR(leaf->musts, u) { |
| 866 | ypr_parsed_restr(ctx, &leaf->musts[u], "must", NULL); |
| 867 | } |
| 868 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, leaf->dflt, leaf->exts); |
| 869 | |
| 870 | ypr_parsed_node_common2(ctx, node, NULL); |
| 871 | |
| 872 | LEVEL--; |
| 873 | ly_print(ctx->out, "%*s}\n", INDENT); |
| 874 | } |
| 875 | |
| 876 | static void |
| 877 | ypr_parsed_leaflist(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 878 | { |
| 879 | unsigned int u; |
| 880 | struct lysp_node_leaflist *llist = (struct lysp_node_leaflist *)node; |
| 881 | |
| 882 | ypr_parsed_node_common1(ctx, node, NULL); |
| 883 | |
| 884 | ypr_parsed_type(ctx, &llist->type); |
| 885 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, llist->units, llist->exts); |
| 886 | LY_ARRAY_FOR(llist->musts, u) { |
| 887 | ypr_parsed_restr(ctx, &llist->musts[u], "must", NULL); |
| 888 | } |
| 889 | LY_ARRAY_FOR(llist->dflts, u) { |
| 890 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, llist->dflts[u], llist->exts); |
| 891 | } |
| 892 | |
| 893 | ypr_parsed_config(ctx, node->flags, node->exts, NULL); |
| 894 | |
| 895 | if (llist->flags & LYS_SET_MIN) { |
| 896 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, llist->exts, llist->min, NULL); |
| 897 | } |
| 898 | if (llist->flags & LYS_SET_MAX) { |
| 899 | if (llist->max) { |
| 900 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, llist->exts, llist->max, NULL); |
| 901 | } else { |
| 902 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", llist->exts); |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | if (llist->flags & LYS_ORDBY_MASK) { |
| 907 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_ORDEREDBY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts); |
| 908 | } |
| 909 | |
| 910 | ypr_parsed_status(ctx, node->flags, node->exts, NULL); |
| 911 | ypr_description(ctx, node->dsc, node->exts, NULL); |
| 912 | ypr_reference(ctx, node->ref, node->exts, NULL); |
| 913 | |
| 914 | LEVEL--; |
| 915 | ly_print(ctx->out, "%*s}\n", INDENT); |
| 916 | } |
| 917 | |
| 918 | static void |
| 919 | ypr_parsed_list(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 920 | { |
| 921 | unsigned int u; |
| 922 | int flag = 0; |
| 923 | struct lysp_node *child; |
| 924 | struct lysp_node_list *list = (struct lysp_node_list *)node; |
| 925 | |
| 926 | ypr_parsed_node_common1(ctx, node, &flag); |
| 927 | |
| 928 | LY_ARRAY_FOR(list->musts, u) { |
| 929 | ypr_parsed_restr(ctx, &list->musts[u], "must", NULL); |
| 930 | } |
| 931 | if (list->key) { |
| 932 | ypr_open(ctx->out, &flag); |
| 933 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_KEY, 0, list->key, list->exts); |
| 934 | } |
| 935 | LY_ARRAY_FOR(list->uniques, u) { |
| 936 | ypr_open(ctx->out, &flag); |
| 937 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, list->uniques[u], list->exts); |
| 938 | } |
| 939 | |
| 940 | ypr_parsed_config(ctx, node->flags, node->exts, NULL); |
| 941 | |
| 942 | if (list->flags & LYS_SET_MIN) { |
| 943 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, list->exts, list->min, NULL); |
| 944 | } |
| 945 | if (list->flags & LYS_SET_MAX) { |
| 946 | if (list->max) { |
| 947 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, list->exts, list->max, NULL); |
| 948 | } else { |
| 949 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", list->exts); |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | if (list->flags & LYS_ORDBY_MASK) { |
| 954 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_ORDEREDBY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts); |
| 955 | } |
| 956 | |
| 957 | ypr_parsed_status(ctx, node->flags, node->exts, NULL); |
| 958 | ypr_description(ctx, node->dsc, node->exts, NULL); |
| 959 | ypr_reference(ctx, node->ref, node->exts, NULL); |
| 960 | |
| 961 | LY_ARRAY_FOR(list->typedefs, u) { |
| 962 | ypr_open(ctx->out, &flag); |
| 963 | ypr_parsed_typedef(ctx, &list->typedefs[u]); |
| 964 | } |
| 965 | |
| 966 | LY_ARRAY_FOR(list->groupings, u) { |
| 967 | ypr_open(ctx->out, &flag); |
| 968 | ypr_parsed_grouping(ctx, &list->groupings[u]); |
| 969 | } |
| 970 | |
| 971 | LY_LIST_FOR(list->child, child) { |
| 972 | ypr_open(ctx->out, &flag); |
| 973 | ypr_parsed_node(ctx, child); |
| 974 | } |
| 975 | |
| 976 | LY_ARRAY_FOR(list->actions, u) { |
| 977 | ypr_open(ctx->out, &flag); |
| 978 | ypr_parsed_action(ctx, &list->actions[u]); |
| 979 | } |
| 980 | |
| 981 | LY_ARRAY_FOR(list->notifs, u) { |
| 982 | ypr_open(ctx->out, &flag); |
| 983 | ypr_parsed_notification(ctx, &list->notifs[u]); |
| 984 | } |
| 985 | |
| 986 | LEVEL--; |
| 987 | ypr_close(ctx, flag); |
| 988 | } |
| 989 | |
| 990 | static void |
| 991 | ypr_parsed_refine(struct ypr_ctx *ctx, struct lysp_refine *refine) |
| 992 | { |
| 993 | unsigned int u; |
| 994 | int flag = 0; |
| 995 | |
| 996 | ly_print(ctx->out, "%*srefine \"%s\"", INDENT, refine->nodeid); |
| 997 | LEVEL++; |
| 998 | |
| 999 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, refine->exts, &flag, 0); |
| 1000 | ypr_parsed_iffeatures(ctx, refine->iffeatures, refine->exts, &flag); |
| 1001 | |
| 1002 | LY_ARRAY_FOR(refine->musts, u) { |
| 1003 | ypr_open(ctx->out, &flag); |
| 1004 | ypr_parsed_restr(ctx, &refine->musts[u], "must", NULL); |
| 1005 | } |
| 1006 | |
| 1007 | if (refine->presence) { |
| 1008 | ypr_open(ctx->out, &flag); |
| 1009 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, refine->presence, refine->exts); |
| 1010 | } |
| 1011 | |
| 1012 | LY_ARRAY_FOR(refine->dflts, u) { |
| 1013 | ypr_open(ctx->out, &flag); |
| 1014 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, refine->dflts[u], refine->exts); |
| 1015 | } |
| 1016 | |
| 1017 | ypr_parsed_config(ctx, refine->flags, refine->exts, &flag); |
| 1018 | ypr_parsed_mandatory(ctx, refine->flags, refine->exts, &flag); |
| 1019 | |
| 1020 | if (refine->flags & LYS_SET_MIN) { |
| 1021 | ypr_open(ctx->out, &flag); |
| 1022 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, refine->exts, refine->min, NULL); |
| 1023 | } |
| 1024 | if (refine->flags & LYS_SET_MAX) { |
| 1025 | ypr_open(ctx->out, &flag); |
| 1026 | if (refine->max) { |
| 1027 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, refine->exts, refine->max, NULL); |
| 1028 | } else { |
| 1029 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", refine->exts); |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | ypr_description(ctx, refine->dsc, refine->exts, &flag); |
| 1034 | ypr_reference(ctx, refine->ref, refine->exts, &flag); |
| 1035 | |
| 1036 | LEVEL--; |
| 1037 | ypr_close(ctx, flag); |
| 1038 | } |
| 1039 | |
| 1040 | static void |
| 1041 | ypr_parsed_augment(struct ypr_ctx *ctx, const struct lysp_augment *aug) |
| 1042 | { |
| 1043 | unsigned int u; |
| 1044 | struct lysp_node *child; |
| 1045 | |
| 1046 | ly_print(ctx->out, "%*saugment \"%s\" {\n", INDENT, aug->nodeid); |
| 1047 | LEVEL++; |
| 1048 | |
| 1049 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, aug->exts, NULL, 0); |
| 1050 | ypr_parsed_when(ctx, aug->when, NULL); |
| 1051 | ypr_parsed_iffeatures(ctx, aug->iffeatures, aug->exts, NULL); |
| 1052 | ypr_parsed_status(ctx, aug->flags, aug->exts, NULL); |
| 1053 | ypr_description(ctx, aug->dsc, aug->exts, NULL); |
| 1054 | ypr_reference(ctx, aug->ref, aug->exts, NULL); |
| 1055 | |
| 1056 | LY_LIST_FOR(aug->child, child) { |
| 1057 | ypr_parsed_node(ctx, child); |
| 1058 | } |
| 1059 | |
| 1060 | LY_ARRAY_FOR(aug->actions, u) { |
| 1061 | ypr_parsed_action(ctx, &aug->actions[u]); |
| 1062 | } |
| 1063 | |
| 1064 | LY_ARRAY_FOR(aug->notifs, u) { |
| 1065 | ypr_parsed_notification(ctx, &aug->notifs[u]); |
| 1066 | } |
| 1067 | |
| 1068 | LEVEL--; |
| 1069 | ly_print(ctx->out, "%*s}\n", INDENT); |
| 1070 | } |
| 1071 | |
| 1072 | |
| 1073 | static void |
| 1074 | ypr_parsed_uses(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 1075 | { |
| 1076 | unsigned int u; |
| 1077 | int flag = 0; |
| 1078 | struct lysp_node_uses *uses = (struct lysp_node_uses *)node; |
| 1079 | |
| 1080 | ypr_parsed_node_common1(ctx, node, &flag); |
| 1081 | ypr_parsed_node_common2(ctx, node, &flag); |
| 1082 | |
| 1083 | LY_ARRAY_FOR(uses->refines, u) { |
| 1084 | ypr_open(ctx->out, &flag); |
| 1085 | ypr_parsed_refine(ctx, &uses->refines[u]); |
| 1086 | } |
| 1087 | |
| 1088 | LY_ARRAY_FOR(uses->augments, u) { |
| 1089 | ypr_open(ctx->out, &flag); |
| 1090 | ypr_parsed_augment(ctx, &uses->augments[u]); |
| 1091 | } |
| 1092 | |
| 1093 | LEVEL--; |
| 1094 | ypr_close(ctx, flag); |
| 1095 | } |
| 1096 | |
| 1097 | static void |
| 1098 | ypr_parsed_anydata(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 1099 | { |
| 1100 | unsigned int u; |
| 1101 | int flag = 0; |
| 1102 | struct lysp_node_anydata *any = (struct lysp_node_anydata *)node; |
| 1103 | |
| 1104 | ypr_parsed_node_common1(ctx, node, &flag); |
| 1105 | |
| 1106 | LY_ARRAY_FOR(any->musts, u) { |
| 1107 | ypr_open(ctx->out, &flag); |
| 1108 | ypr_parsed_restr(ctx, &any->musts[u], "must", NULL); |
| 1109 | } |
| 1110 | |
| 1111 | ypr_parsed_node_common2(ctx, node, &flag); |
| 1112 | |
| 1113 | LEVEL--; |
| 1114 | ypr_close(ctx, flag); |
| 1115 | } |
| 1116 | |
| 1117 | static void |
| 1118 | ypr_parsed_case(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 1119 | { |
| 1120 | int flag = 0; |
| 1121 | struct lysp_node *child; |
| 1122 | struct lysp_node_case *cas = (struct lysp_node_case *)node; |
| 1123 | |
| 1124 | ypr_parsed_node_common1(ctx, node, &flag); |
| 1125 | ypr_parsed_node_common2(ctx, node, &flag); |
| 1126 | |
| 1127 | LY_LIST_FOR(cas->child, child) { |
| 1128 | ypr_open(ctx->out, &flag); |
| 1129 | ypr_parsed_node(ctx, child); |
| 1130 | } |
| 1131 | |
| 1132 | LEVEL--; |
| 1133 | ypr_close(ctx, flag); |
| 1134 | } |
| 1135 | |
| 1136 | static void |
| 1137 | ypr_parsed_node(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 1138 | { |
| 1139 | switch (node->nodetype) { |
| 1140 | case LYS_CONTAINER: |
| 1141 | ypr_parsed_container(ctx, node); |
| 1142 | break; |
| 1143 | case LYS_CHOICE: |
| 1144 | ypr_parsed_choice(ctx, node); |
| 1145 | break; |
| 1146 | case LYS_LEAF: |
| 1147 | ypr_parsed_leaf(ctx, node); |
| 1148 | break; |
| 1149 | case LYS_LEAFLIST: |
| 1150 | ypr_parsed_leaflist(ctx, node); |
| 1151 | break; |
| 1152 | case LYS_LIST: |
| 1153 | ypr_parsed_list(ctx, node); |
| 1154 | break; |
| 1155 | case LYS_USES: |
| 1156 | ypr_parsed_uses(ctx, node); |
| 1157 | break; |
| 1158 | case LYS_ANYXML: |
| 1159 | case LYS_ANYDATA: |
| 1160 | ypr_parsed_anydata(ctx, node); |
| 1161 | break; |
| 1162 | case LYS_CASE: |
| 1163 | ypr_parsed_case(ctx, node); |
| 1164 | break; |
| 1165 | default: |
| 1166 | break; |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | static void |
| 1171 | ypr_parsed_deviation(struct ypr_ctx *ctx, const struct lysp_deviation *deviation) |
| 1172 | { |
| 1173 | unsigned int u, v; |
| 1174 | struct lysp_deviate_add *add; |
| 1175 | struct lysp_deviate_rpl *rpl; |
| 1176 | struct lysp_deviate_del *del; |
| 1177 | |
| 1178 | ly_print(ctx->out, "%*sdeviation \"%s\" {\n", INDENT, deviation->nodeid); |
| 1179 | LEVEL++; |
| 1180 | |
| 1181 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, deviation->exts, NULL, 0); |
| 1182 | ypr_description(ctx, deviation->dsc, deviation->exts, NULL); |
| 1183 | ypr_reference(ctx, deviation->ref, deviation->exts, NULL); |
| 1184 | |
| 1185 | LY_ARRAY_FOR(deviation->deviates, u) { |
| 1186 | ly_print(ctx->out, "%*sdeviate ", INDENT); |
| 1187 | if (deviation->deviates[u].mod == LYS_DEV_NOT_SUPPORTED) { |
| 1188 | if (deviation->deviates[u].exts) { |
| 1189 | ly_print(ctx->out, "not-supported {\n"); |
| 1190 | LEVEL++; |
| 1191 | |
| 1192 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, deviation->deviates[u].exts, NULL, 0); |
| 1193 | } else { |
| 1194 | ly_print(ctx->out, "not-supported;\n"); |
| 1195 | continue; |
| 1196 | } |
| 1197 | } else if (deviation->deviates[u].mod == LYS_DEV_ADD) { |
| 1198 | add = (struct lysp_deviate_add*)&deviation->deviates[u]; |
| 1199 | ly_print(ctx->out, "add {\n"); |
| 1200 | LEVEL++; |
| 1201 | |
| 1202 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, add->exts, NULL, 0); |
| 1203 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, add->units, add->exts); |
| 1204 | LY_ARRAY_FOR(add->musts, v) { |
| 1205 | ypr_parsed_restr(ctx, &add->musts[v], "must", NULL); |
| 1206 | } |
| 1207 | LY_ARRAY_FOR(add->uniques, v) { |
| 1208 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, v, add->uniques[v], add->exts); |
| 1209 | } |
| 1210 | LY_ARRAY_FOR(add->dflts, v) { |
| 1211 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, v, add->dflts[v], add->exts); |
| 1212 | } |
| 1213 | ypr_parsed_config(ctx, add->flags, add->exts, NULL); |
| 1214 | ypr_parsed_mandatory(ctx, add->flags, add->exts, NULL); |
| 1215 | if (add->flags & LYS_SET_MIN) { |
| 1216 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, add->exts, add->min, NULL); |
| 1217 | } |
| 1218 | if (add->flags & LYS_SET_MAX) { |
| 1219 | if (add->max) { |
| 1220 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, add->exts, add->max, NULL); |
| 1221 | } else { |
| 1222 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", add->exts); |
| 1223 | } |
| 1224 | } |
| 1225 | } else if (deviation->deviates[u].mod == LYS_DEV_REPLACE) { |
| 1226 | rpl = (struct lysp_deviate_rpl*)&deviation->deviates[u]; |
| 1227 | ly_print(ctx->out, "replace {\n"); |
| 1228 | LEVEL++; |
| 1229 | |
| 1230 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, rpl->exts, NULL, 0); |
| 1231 | if (rpl->type) { |
| 1232 | ypr_parsed_type(ctx, rpl->type); |
| 1233 | } |
| 1234 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, rpl->units, rpl->exts); |
| 1235 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, v, rpl->dflt, rpl->exts); |
| 1236 | ypr_parsed_config(ctx, rpl->flags, rpl->exts, NULL); |
| 1237 | ypr_parsed_mandatory(ctx, rpl->flags, rpl->exts, NULL); |
| 1238 | if (rpl->flags & LYS_SET_MIN) { |
| 1239 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, rpl->exts, rpl->min, NULL); |
| 1240 | } |
| 1241 | if (rpl->flags & LYS_SET_MAX) { |
| 1242 | if (rpl->max) { |
| 1243 | ypr_parsed_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, rpl->exts, rpl->max, NULL); |
| 1244 | } else { |
| 1245 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", rpl->exts); |
| 1246 | } |
| 1247 | } |
| 1248 | } else if (deviation->deviates[u].mod == LYS_DEV_DELETE) { |
| 1249 | del = (struct lysp_deviate_del*)&deviation->deviates[u]; |
| 1250 | ly_print(ctx->out, "delete {\n"); |
| 1251 | LEVEL++; |
| 1252 | |
| 1253 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, del->exts, NULL, 0); |
| 1254 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, del->units, del->exts); |
| 1255 | LY_ARRAY_FOR(del->musts, v) { |
| 1256 | ypr_parsed_restr(ctx, &del->musts[v], "must", NULL); |
| 1257 | } |
| 1258 | LY_ARRAY_FOR(del->uniques, v) { |
| 1259 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, v, del->uniques[v], del->exts); |
| 1260 | } |
| 1261 | LY_ARRAY_FOR(del->dflts, v) { |
| 1262 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, v, del->dflts[v], del->exts); |
| 1263 | } |
| 1264 | } |
| 1265 | |
| 1266 | LEVEL--; |
| 1267 | ypr_close(ctx, 1); |
| 1268 | } |
| 1269 | |
| 1270 | LEVEL--; |
| 1271 | ypr_close(ctx, 1); |
| 1272 | } |
| 1273 | |
| 1274 | LY_ERR |
| 1275 | yang_print_parsed(struct lyout *out, const struct lys_module *module) |
| 1276 | { |
| 1277 | unsigned int u; |
| 1278 | struct lysp_node *data; |
| 1279 | struct lysp_module *modp = module->parsed; |
| 1280 | struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module}, *ctx = &ctx_; |
| 1281 | |
| 1282 | ly_print(ctx->out, "%*smodule %s {\n", INDENT, module->name); |
| 1283 | LEVEL++; |
| 1284 | |
| 1285 | /* module-header-stmts */ |
| 1286 | if (module->version) { |
| 1287 | if (module->version) { |
| 1288 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_VERSION, 0, module->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts); |
| 1289 | } |
| 1290 | } |
| 1291 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_NAMESPACE, 0, module->ns, modp->exts); |
| 1292 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, module->prefix, modp->exts); |
| 1293 | |
| 1294 | /* linkage-stmts */ |
| 1295 | LY_ARRAY_FOR(modp->imports, u) { |
| 1296 | ly_print(out, "\n%*simport %s {\n", INDENT, modp->imports[u].module->name); |
| 1297 | LEVEL++; |
| 1298 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->imports[u].exts, NULL, 0); |
| 1299 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts); |
| 1300 | if (modp->imports[u].rev[0]) { |
| 1301 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REVISIONDATE, 0, modp->imports[u].rev, modp->imports[u].exts); |
| 1302 | } |
| 1303 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts); |
| 1304 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts); |
| 1305 | LEVEL--; |
| 1306 | ly_print(out, "%*s}\n", INDENT); |
| 1307 | } |
| 1308 | LY_ARRAY_FOR(modp->includes, u) { |
| 1309 | if (modp->includes[u].rev[0] || modp->includes[u].dsc || modp->includes[u].ref || modp->includes[u].exts) { |
| 1310 | ly_print(out, "\n%*sinclude %s {\n", INDENT, modp->includes[u].submodule->name); |
| 1311 | LEVEL++; |
| 1312 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->includes[u].exts, NULL, 0); |
| 1313 | if (modp->includes[u].rev[0]) { |
| 1314 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REVISIONDATE, 0, modp->includes[u].rev, modp->includes[u].exts); |
| 1315 | } |
| 1316 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts); |
| 1317 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts); |
| 1318 | LEVEL--; |
| 1319 | ly_print(out, "%*s}\n", INDENT); |
| 1320 | } else { |
| 1321 | ly_print(out, "\n%*sinclude \"%s\";\n", INDENT, modp->includes[u].submodule->name); |
| 1322 | } |
| 1323 | } |
| 1324 | |
| 1325 | /* meta-stmts */ |
| 1326 | if (module->org || module->contact || module->dsc || module->ref) { |
| 1327 | ly_print(out, "\n"); |
| 1328 | } |
| 1329 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, module->org, modp->exts); |
| 1330 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, module->contact, modp->exts); |
| 1331 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, module->dsc, modp->exts); |
| 1332 | ypr_parsed_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, module->ref, modp->exts); |
| 1333 | |
| 1334 | /* revision-stmts */ |
| 1335 | if (modp->revs) { |
| 1336 | ly_print(out, "\n"); |
| 1337 | } |
| 1338 | LY_ARRAY_FOR(modp->revs, u) { |
| 1339 | ypr_parsed_revision(ctx, &modp->revs[u]); |
| 1340 | } |
| 1341 | /* body-stmts */ |
| 1342 | LY_ARRAY_FOR(modp->extensions, u) { |
| 1343 | ly_print(out, "\n"); |
| 1344 | ypr_parsed_extension(ctx, &modp->extensions[u]); |
| 1345 | } |
| 1346 | if (modp->exts) { |
| 1347 | ly_print(out, "\n"); |
| 1348 | ypr_parsed_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, module->parsed->exts, NULL, 0); |
| 1349 | } |
| 1350 | |
| 1351 | LY_ARRAY_FOR(modp->features, u) { |
| 1352 | ypr_parsed_feature(ctx, &modp->features[u]); |
| 1353 | } |
| 1354 | |
| 1355 | LY_ARRAY_FOR(modp->identities, u) { |
| 1356 | ypr_parsed_identity(ctx, &modp->identities[u]); |
| 1357 | } |
| 1358 | |
| 1359 | LY_ARRAY_FOR(modp->typedefs, u) { |
| 1360 | ypr_parsed_typedef(ctx, &modp->typedefs[u]); |
| 1361 | } |
| 1362 | |
| 1363 | LY_ARRAY_FOR(modp->groupings, u) { |
| 1364 | ypr_parsed_grouping(ctx, &modp->groupings[u]); |
| 1365 | } |
| 1366 | |
| 1367 | LY_LIST_FOR(modp->data, data) { |
| 1368 | ypr_parsed_node(ctx, data); |
| 1369 | } |
| 1370 | |
| 1371 | LY_ARRAY_FOR(modp->augments, u) { |
| 1372 | ypr_parsed_augment(ctx, &modp->augments[u]); |
| 1373 | } |
| 1374 | |
| 1375 | LY_ARRAY_FOR(modp->rpcs, u) { |
| 1376 | ypr_parsed_action(ctx, &modp->rpcs[u]); |
| 1377 | } |
| 1378 | |
| 1379 | LY_ARRAY_FOR(modp->notifs, u) { |
| 1380 | ypr_parsed_notification(ctx, &modp->notifs[u]); |
| 1381 | } |
| 1382 | |
| 1383 | LY_ARRAY_FOR(modp->deviations, u) { |
| 1384 | ypr_parsed_deviation(ctx, &modp->deviations[u]); |
| 1385 | } |
| 1386 | |
| 1387 | LEVEL--; |
| 1388 | ly_print(out, "%*s}\n", INDENT); |
| 1389 | ly_print_flush(out); |
| 1390 | |
| 1391 | return LY_SUCCESS; |
| 1392 | } |
| 1393 | |
| 1394 | LY_ERR |
| 1395 | yang_print_compiled(struct lyout *out, const struct lys_module *module) |
| 1396 | { |
| 1397 | (void) out; |
| 1398 | (void) module; |
| 1399 | |
| 1400 | return LY_SUCCESS; |
| 1401 | } |