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 | |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 15 | #define _GNU_SOURCE |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 16 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 17 | #include <inttypes.h> |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 18 | #include <stdint.h> |
| 19 | #include <stdio.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <string.h> |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 22 | #include <sys/types.h> |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 23 | |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 24 | #include "common.h" |
Radek Krejci | aa45bda | 2020-07-20 07:43:38 +0200 | [diff] [blame] | 25 | #include "compat.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 26 | #include "log.h" |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 27 | #include "out.h" |
Michal Vasko | afac782 | 2020-10-20 14:22:26 +0200 | [diff] [blame] | 28 | #include "out_internal.h" |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 29 | #include "plugins_types.h" |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 30 | #include "printer_internal.h" |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 31 | #include "printer_schema.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 32 | #include "tree.h" |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 33 | #include "tree_data.h" |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 34 | #include "tree_schema.h" |
| 35 | #include "tree_schema_internal.h" |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 36 | #include "xpath.h" |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 37 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 38 | /** |
| 39 | * @brief Types of the YANG printers |
| 40 | */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 41 | enum schema_type { |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 42 | YPR_PARSED, /**< YANG printer of the parsed schema */ |
| 43 | YPR_COMPILED /**< YANG printer of the compiled schema */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 44 | }; |
| 45 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 46 | /** |
| 47 | * @brief YANG printer context. |
| 48 | */ |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 49 | struct ypr_ctx { |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 50 | struct ly_out *out; /**< output specification */ |
| 51 | uint16_t level; /**< current indentation level: 0 - no formatting, >= 1 indentation levels */ |
| 52 | uint32_t options; /**< Schema output options (see @ref schemaprinterflags). */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 53 | const struct lys_module *module; /**< schema to print */ |
| 54 | enum schema_type schema; /**< type of the schema to print */ |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 55 | }; |
| 56 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 57 | /** |
| 58 | * @brief Print the given text as content of a double quoted YANG string, |
| 59 | * including encoding characters that have special meanings. The quotation marks |
| 60 | * are not printed. |
| 61 | * |
| 62 | * Follows RFC 7950, section 6.1.3. |
| 63 | * |
| 64 | * @param[in] out Output specification. |
| 65 | * @param[in] text String to be printed. |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 66 | * @param[in] len Length of the string from @p text to be printed. In case of -1, |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 67 | * the @p text is printed completely as a NULL-terminated string. |
| 68 | */ |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 69 | static void |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 70 | ypr_encode(struct ly_out *out, const char *text, ssize_t len) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 71 | { |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 72 | size_t i, start_len; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 73 | const char *start; |
| 74 | char special = 0; |
| 75 | |
| 76 | if (!len) { |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | if (len < 0) { |
| 81 | len = strlen(text); |
| 82 | } |
| 83 | |
| 84 | start = text; |
| 85 | start_len = 0; |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 86 | for (i = 0; i < (size_t)len; ++i) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 87 | switch (text[i]) { |
| 88 | case '\n': |
| 89 | case '\t': |
| 90 | case '\"': |
| 91 | case '\\': |
| 92 | special = text[i]; |
| 93 | break; |
| 94 | default: |
| 95 | ++start_len; |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | if (special) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 100 | ly_write_(out, start, start_len); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 101 | switch (special) { |
| 102 | case '\n': |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 103 | ly_write_(out, "\\n", 2); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 104 | break; |
| 105 | case '\t': |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 106 | ly_write_(out, "\\t", 2); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 107 | break; |
| 108 | case '\"': |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 109 | ly_write_(out, "\\\"", 2); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 110 | break; |
| 111 | case '\\': |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 112 | ly_write_(out, "\\\\", 2); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 113 | break; |
| 114 | } |
| 115 | |
| 116 | start += start_len + 1; |
| 117 | start_len = 0; |
| 118 | |
| 119 | special = 0; |
| 120 | } |
| 121 | } |
| 122 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 123 | ly_write_(out, start, start_len); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 127 | ypr_open(struct ly_out *out, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 128 | { |
| 129 | if (flag && !*flag) { |
| 130 | *flag = 1; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 131 | ly_print_(out, " {\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
| 135 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 136 | ypr_close(struct ypr_ctx *ctx, ly_bool flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 137 | { |
| 138 | if (flag) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 139 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 140 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 141 | ly_print_(ctx->out, ";\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | |
| 145 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 146 | ypr_text(struct ypr_ctx *ctx, const char *name, const char *text, ly_bool singleline, ly_bool closed) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 147 | { |
| 148 | const char *s, *t; |
| 149 | |
| 150 | if (singleline) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 151 | ly_print_(ctx->out, "%*s%s \"", INDENT, name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 152 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 153 | ly_print_(ctx->out, "%*s%s\n", INDENT, name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 154 | LEVEL++; |
| 155 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 156 | ly_print_(ctx->out, "%*s\"", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 157 | } |
| 158 | t = text; |
| 159 | while ((s = strchr(t, '\n'))) { |
| 160 | ypr_encode(ctx->out, t, s - t); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 161 | ly_print_(ctx->out, "\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 162 | t = s + 1; |
| 163 | if (*t != '\n') { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 164 | ly_print_(ctx->out, "%*s ", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | |
| 168 | ypr_encode(ctx->out, t, strlen(t)); |
| 169 | if (closed) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 170 | ly_print_(ctx->out, "\";\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 171 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 172 | ly_print_(ctx->out, "\""); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 173 | } |
| 174 | if (!singleline) { |
| 175 | LEVEL--; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 180 | yprp_stmt(struct ypr_ctx *ctx, struct lysp_stmt *stmt) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 181 | { |
| 182 | struct lysp_stmt *childstmt; |
| 183 | const char *s, *t; |
| 184 | |
| 185 | if (stmt->arg) { |
| 186 | if (stmt->flags) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 187 | ly_print_(ctx->out, "%*s%s\n", INDENT, stmt->stmt); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 188 | LEVEL++; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 189 | ly_print_(ctx->out, "%*s%c", INDENT, (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\''); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 190 | t = stmt->arg; |
| 191 | while ((s = strchr(t, '\n'))) { |
| 192 | ypr_encode(ctx->out, t, s - t); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 193 | ly_print_(ctx->out, "\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 194 | t = s + 1; |
| 195 | if (*t != '\n') { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 196 | ly_print_(ctx->out, "%*s ", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | LEVEL--; |
| 200 | ypr_encode(ctx->out, t, strlen(t)); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 201 | ly_print_(ctx->out, "%c%s", (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\'', stmt->child ? " {\n" : ";\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 202 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 203 | ly_print_(ctx->out, "%*s%s %s%s", INDENT, stmt->stmt, stmt->arg, stmt->child ? " {\n" : ";\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 204 | } |
| 205 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 206 | ly_print_(ctx->out, "%*s%s%s", INDENT, stmt->stmt, stmt->child ? " {\n" : ";\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | if (stmt->child) { |
| 210 | LEVEL++; |
| 211 | LY_LIST_FOR(stmt->child, childstmt) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 212 | yprp_stmt(ctx, childstmt); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 213 | } |
| 214 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 215 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * @param[in] count Number of extensions to print, 0 to print them all. |
| 221 | */ |
| 222 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 223 | yprp_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 224 | struct lysp_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 225 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 226 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 227 | struct lysp_stmt *stmt; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 228 | ly_bool child_presence; |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 229 | const char *argument; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 230 | |
| 231 | if (!count && ext) { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 232 | count = LY_ARRAY_COUNT(ext); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 233 | } |
| 234 | LY_ARRAY_FOR(ext, u) { |
| 235 | if (!count) { |
| 236 | break; |
| 237 | } |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 238 | |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 239 | count--; |
Michal Vasko | 3e9bc2f | 2020-11-04 17:13:56 +0100 | [diff] [blame] | 240 | if ((ext->flags & LYS_INTERNAL) || (ext->insubstmt != substmt) || (ext->insubstmt_index != substmt_index)) { |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 241 | continue; |
| 242 | } |
| 243 | |
| 244 | if (!ext->compiled && ext->yin) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 245 | ly_print_(ctx->out, "%*s%s; // Model comes from different input format, extensions must be resolved first.\n", INDENT, ext[u].name); |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 246 | continue; |
| 247 | } |
| 248 | |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 249 | ypr_open(ctx->out, flag); |
| 250 | argument = NULL; |
| 251 | if (ext[u].compiled) { |
| 252 | argument = ext[u].compiled->argument; |
| 253 | } else { |
| 254 | argument = ext[u].argument; |
| 255 | } |
| 256 | if (argument) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 257 | ly_print_(ctx->out, "%*s%s \"", INDENT, ext[u].name); |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 258 | ypr_encode(ctx->out, argument, -1); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 259 | ly_print_(ctx->out, "\""); |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 260 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 261 | ly_print_(ctx->out, "%*s%s", INDENT, ext[u].name); |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | child_presence = 0; |
| 265 | LEVEL++; |
| 266 | LY_LIST_FOR(ext[u].child, stmt) { |
| 267 | if (stmt->flags & (LYS_YIN_ATTR | LYS_YIN_ARGUMENT)) { |
| 268 | continue; |
| 269 | } |
| 270 | if (!child_presence) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 271 | ly_print_(ctx->out, " {\n"); |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 272 | child_presence = 1; |
| 273 | } |
| 274 | yprp_stmt(ctx, stmt); |
| 275 | } |
| 276 | LEVEL--; |
| 277 | if (child_presence) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 278 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 279 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 280 | ly_print_(ctx->out, ";\n"); |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 281 | } |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 285 | /** |
| 286 | * @param[in] count Number of extensions to print, 0 to print them all. |
| 287 | */ |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 288 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 289 | yprc_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 290 | struct lysc_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count) |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 291 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 292 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 293 | |
| 294 | if (!count && ext) { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 295 | count = LY_ARRAY_COUNT(ext); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 296 | } |
| 297 | LY_ARRAY_FOR(ext, u) { |
| 298 | if (!count) { |
| 299 | break; |
| 300 | } |
| 301 | /* TODO compiled extensions */ |
| 302 | (void) ctx; |
| 303 | (void) substmt; |
| 304 | (void) substmt_index; |
| 305 | (void) flag; |
| 306 | |
| 307 | count--; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | static void |
| 312 | ypr_substmt(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, const char *text, void *ext) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 313 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 314 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 315 | ly_bool extflag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 316 | |
| 317 | if (!text) { |
| 318 | /* nothing to print */ |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | if (ext_substmt_info[substmt].flags & SUBST_FLAG_ID) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 323 | ly_print_(ctx->out, "%*s%s %s", INDENT, ext_substmt_info[substmt].name, text); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 324 | } else { |
| 325 | ypr_text(ctx, ext_substmt_info[substmt].name, text, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 326 | (ext_substmt_info[substmt].flags & SUBST_FLAG_YIN) ? 0 : 1, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | LEVEL++; |
| 330 | LY_ARRAY_FOR(ext, u) { |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 331 | if ((((struct lysp_ext_instance *)ext)[u].insubstmt != substmt) || (((struct lysp_ext_instance *)ext)[u].insubstmt_index != substmt_index)) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 332 | continue; |
| 333 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 334 | if (ctx->schema == YPR_PARSED) { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 335 | yprp_extension_instances(ctx, substmt, substmt_index, &((struct lysp_ext_instance *)ext)[u], &extflag, 1); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 336 | } else { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 337 | yprc_extension_instances(ctx, substmt, substmt_index, &((struct lysc_ext_instance *)ext)[u], &extflag, 1); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 338 | } |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 339 | } |
| 340 | LEVEL--; |
| 341 | ypr_close(ctx, extflag); |
| 342 | } |
| 343 | |
| 344 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 345 | ypr_unsigned(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 346 | { |
| 347 | char *str; |
| 348 | |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 349 | if (asprintf(&str, "%lu", attr_value) == -1) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 350 | LOGMEM(ctx->module->ctx); |
| 351 | return; |
| 352 | } |
| 353 | ypr_open(ctx->out, flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 354 | ypr_substmt(ctx, substmt, substmt_index, str, exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 355 | free(str); |
| 356 | } |
| 357 | |
| 358 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 359 | ypr_signed(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, signed long int attr_value, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 360 | { |
| 361 | char *str; |
| 362 | |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 363 | if (asprintf(&str, "%ld", attr_value) == -1) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 364 | LOGMEM(ctx->module->ctx); |
| 365 | return; |
| 366 | } |
| 367 | ypr_open(ctx->out, flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 368 | ypr_substmt(ctx, substmt, substmt_index, str, exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 369 | free(str); |
| 370 | } |
| 371 | |
| 372 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 373 | yprp_revision(struct ypr_ctx *ctx, const struct lysp_revision *rev) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 374 | { |
| 375 | if (rev->dsc || rev->ref || rev->exts) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 376 | ly_print_(ctx->out, "%*srevision %s {\n", INDENT, rev->date); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 377 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 378 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, rev->exts, NULL, 0); |
| 379 | ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, rev->dsc, rev->exts); |
| 380 | ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, rev->ref, rev->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 381 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 382 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 383 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 384 | ly_print_(ctx->out, "%*srevision %s;\n", INDENT, rev->date); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | |
| 388 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 389 | ypr_mandatory(struct ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 390 | { |
| 391 | if (flags & LYS_MAND_MASK) { |
| 392 | ypr_open(ctx->out, flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 393 | ypr_substmt(ctx, LYEXT_SUBSTMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 394 | } |
| 395 | } |
| 396 | |
| 397 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 398 | ypr_config(struct ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 399 | { |
| 400 | if (flags & LYS_CONFIG_MASK) { |
| 401 | ypr_open(ctx->out, flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 402 | ypr_substmt(ctx, LYEXT_SUBSTMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 403 | } |
| 404 | } |
| 405 | |
| 406 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 407 | ypr_status(struct ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 408 | { |
| 409 | const char *status = NULL; |
| 410 | |
| 411 | if (flags & LYS_STATUS_CURR) { |
| 412 | ypr_open(ctx->out, flag); |
| 413 | status = "current"; |
| 414 | } else if (flags & LYS_STATUS_DEPRC) { |
| 415 | ypr_open(ctx->out, flag); |
| 416 | status = "deprecated"; |
| 417 | } else if (flags & LYS_STATUS_OBSLT) { |
| 418 | ypr_open(ctx->out, flag); |
| 419 | status = "obsolete"; |
| 420 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 421 | |
| 422 | ypr_substmt(ctx, LYEXT_SUBSTMT_STATUS, 0, status, exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 426 | ypr_description(struct ypr_ctx *ctx, const char *dsc, void *exts, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 427 | { |
| 428 | if (dsc) { |
| 429 | ypr_open(ctx->out, flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 430 | ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, dsc, exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 431 | } |
| 432 | } |
| 433 | |
| 434 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 435 | ypr_reference(struct ypr_ctx *ctx, const char *ref, void *exts, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 436 | { |
| 437 | if (ref) { |
| 438 | ypr_open(ctx->out, flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 439 | ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, ref, exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | |
| 443 | static void |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 444 | yprp_iffeatures(struct ypr_ctx *ctx, struct lysp_qname *iffs, struct lysp_ext_instance *exts, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 445 | { |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 446 | LY_ARRAY_COUNT_TYPE u, v; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 447 | ly_bool extflag; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 448 | |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 449 | LY_ARRAY_FOR(iffs, u) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 450 | ypr_open(ctx->out, flag); |
| 451 | extflag = 0; |
| 452 | |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 453 | ly_print_(ctx->out, "%*sif-feature \"%s\"", INDENT, iffs[u].str); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 454 | |
| 455 | /* extensions */ |
| 456 | LEVEL++; |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 457 | LY_ARRAY_FOR(exts, v) { |
| 458 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_IFFEATURE, u, &exts[v], &extflag, 1); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 459 | } |
| 460 | LEVEL--; |
| 461 | ypr_close(ctx, extflag); |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 466 | yprp_extension(struct ypr_ctx *ctx, const struct lysp_ext *ext) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 467 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 468 | ly_bool flag = 0, flag2 = 0; |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 469 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 470 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 471 | ly_print_(ctx->out, "%*sextension %s", INDENT, ext->name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 472 | LEVEL++; |
| 473 | |
| 474 | if (ext->exts) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 475 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ext->exts, &flag, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | if (ext->argument) { |
| 479 | ypr_open(ctx->out, &flag); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 480 | ly_print_(ctx->out, "%*sargument %s", INDENT, ext->argument); |
Radek Krejci | 38d2e9f | 2019-09-09 10:31:51 +0200 | [diff] [blame] | 481 | LEVEL++; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 482 | if (ext->exts) { |
Radek Krejci | 7eb54ba | 2020-05-18 16:30:04 +0200 | [diff] [blame] | 483 | u = -1; |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 484 | while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LYEXT_SUBSTMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) { |
Radek Krejci | 7eb54ba | 2020-05-18 16:30:04 +0200 | [diff] [blame] | 485 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 486 | } |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 487 | } |
| 488 | if ((ext->flags & LYS_YINELEM_MASK) || |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 489 | (ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_COUNT(ext->exts)))) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 490 | ypr_open(ctx->out, &flag2); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 491 | ypr_substmt(ctx, LYEXT_SUBSTMT_YINELEM, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 492 | } |
Radek Krejci | 38d2e9f | 2019-09-09 10:31:51 +0200 | [diff] [blame] | 493 | LEVEL--; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 494 | ypr_close(ctx, flag2); |
| 495 | } |
| 496 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 497 | ypr_status(ctx, ext->flags, ext->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 498 | ypr_description(ctx, ext->dsc, ext->exts, &flag); |
| 499 | ypr_reference(ctx, ext->ref, ext->exts, &flag); |
| 500 | |
| 501 | LEVEL--; |
| 502 | ypr_close(ctx, flag); |
| 503 | } |
| 504 | |
| 505 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 506 | yprp_feature(struct ypr_ctx *ctx, const struct lysp_feature *feat) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 507 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 508 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 509 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 510 | ly_print_(ctx->out, "\n%*sfeature %s", INDENT, feat->name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 511 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 512 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, feat->exts, &flag, 0); |
| 513 | yprp_iffeatures(ctx, feat->iffeatures, feat->exts, &flag); |
| 514 | ypr_status(ctx, feat->flags, feat->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 515 | ypr_description(ctx, feat->dsc, feat->exts, &flag); |
| 516 | ypr_reference(ctx, feat->ref, feat->exts, &flag); |
| 517 | LEVEL--; |
| 518 | ypr_close(ctx, flag); |
| 519 | } |
| 520 | |
| 521 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 522 | yprp_identity(struct ypr_ctx *ctx, const struct lysp_ident *ident) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 523 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 524 | ly_bool flag = 0; |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 525 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 526 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 527 | ly_print_(ctx->out, "\n%*sidentity %s", INDENT, ident->name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 528 | LEVEL++; |
| 529 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 530 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ident->exts, &flag, 0); |
| 531 | yprp_iffeatures(ctx, ident->iffeatures, ident->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 532 | |
| 533 | LY_ARRAY_FOR(ident->bases, u) { |
| 534 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 535 | ypr_substmt(ctx, LYEXT_SUBSTMT_BASE, u, ident->bases[u], ident->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 536 | } |
| 537 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 538 | ypr_status(ctx, ident->flags, ident->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 539 | ypr_description(ctx, ident->dsc, ident->exts, &flag); |
| 540 | ypr_reference(ctx, ident->ref, ident->exts, &flag); |
| 541 | |
| 542 | LEVEL--; |
| 543 | ypr_close(ctx, flag); |
| 544 | } |
| 545 | |
| 546 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 547 | yprc_identity(struct ypr_ctx *ctx, const struct lysc_ident *ident) |
| 548 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 549 | ly_bool flag = 0; |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 550 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 551 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 552 | ly_print_(ctx->out, "\n%*sidentity %s", INDENT, ident->name); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 553 | LEVEL++; |
| 554 | |
| 555 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ident->exts, &flag, 0); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 556 | |
| 557 | LY_ARRAY_FOR(ident->derived, u) { |
| 558 | ypr_open(ctx->out, &flag); |
| 559 | if (ctx->module != ident->derived[u]->module) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 560 | ly_print_(ctx->out, "%*sderived %s:%s;\n", INDENT, ident->derived[u]->module->prefix, ident->derived[u]->name); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 561 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 562 | ly_print_(ctx->out, "%*sderived %s;\n", INDENT, ident->derived[u]->name); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 563 | } |
| 564 | } |
| 565 | |
| 566 | ypr_status(ctx, ident->flags, ident->exts, &flag); |
| 567 | ypr_description(ctx, ident->dsc, ident->exts, &flag); |
| 568 | ypr_reference(ctx, ident->ref, ident->exts, &flag); |
| 569 | |
| 570 | LEVEL--; |
| 571 | ypr_close(ctx, flag); |
| 572 | } |
| 573 | |
| 574 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 575 | yprp_restr(struct ypr_ctx *ctx, const struct lysp_restr *restr, const char *name, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 576 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 577 | ly_bool inner_flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 578 | |
| 579 | if (!restr) { |
| 580 | return; |
| 581 | } |
| 582 | |
| 583 | ypr_open(ctx->out, flag); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 584 | ly_print_(ctx->out, "%*s%s \"", INDENT, name); |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 585 | ypr_encode(ctx->out, (restr->arg.str[0] != 0x15 && restr->arg.str[0] != 0x06) ? restr->arg.str : &restr->arg.str[1], -1); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 586 | ly_print_(ctx->out, "\""); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 587 | |
| 588 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 589 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, restr->exts, &inner_flag, 0); |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 590 | if (restr->arg.str[0] == 0x15) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 591 | /* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */ |
| 592 | ypr_open(ctx->out, &inner_flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 593 | ypr_substmt(ctx, LYEXT_SUBSTMT_MODIFIER, 0, "invert-match", restr->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 594 | } |
| 595 | if (restr->emsg) { |
| 596 | ypr_open(ctx->out, &inner_flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 597 | ypr_substmt(ctx, LYEXT_SUBSTMT_ERRMSG, 0, restr->emsg, restr->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 598 | } |
| 599 | if (restr->eapptag) { |
| 600 | ypr_open(ctx->out, &inner_flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 601 | ypr_substmt(ctx, LYEXT_SUBSTMT_ERRTAG, 0, restr->eapptag, restr->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 602 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 603 | ypr_description(ctx, restr->dsc, restr->exts, &inner_flag); |
| 604 | ypr_reference(ctx, restr->ref, restr->exts, &inner_flag); |
| 605 | |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 606 | LEVEL--; |
| 607 | ypr_close(ctx, inner_flag); |
| 608 | } |
| 609 | |
| 610 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 611 | yprc_must(struct ypr_ctx *ctx, const struct lysc_must *must, ly_bool *flag) |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 612 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 613 | ly_bool inner_flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 614 | |
| 615 | ypr_open(ctx->out, flag); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 616 | ly_print_(ctx->out, "%*smust \"", INDENT); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 617 | ypr_encode(ctx->out, must->cond->expr, -1); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 618 | ly_print_(ctx->out, "\""); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 619 | |
| 620 | LEVEL++; |
| 621 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, must->exts, &inner_flag, 0); |
| 622 | if (must->emsg) { |
| 623 | ypr_open(ctx->out, &inner_flag); |
| 624 | ypr_substmt(ctx, LYEXT_SUBSTMT_ERRMSG, 0, must->emsg, must->exts); |
| 625 | } |
| 626 | if (must->eapptag) { |
| 627 | ypr_open(ctx->out, &inner_flag); |
| 628 | ypr_substmt(ctx, LYEXT_SUBSTMT_ERRTAG, 0, must->eapptag, must->exts); |
| 629 | } |
| 630 | ypr_description(ctx, must->dsc, must->exts, &inner_flag); |
| 631 | ypr_reference(ctx, must->ref, must->exts, &inner_flag); |
| 632 | |
| 633 | LEVEL--; |
| 634 | ypr_close(ctx, inner_flag); |
| 635 | } |
| 636 | |
| 637 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 638 | yprc_range(struct ypr_ctx *ctx, const struct lysc_range *range, LY_DATA_TYPE basetype, ly_bool *flag) |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 639 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 640 | ly_bool inner_flag = 0; |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 641 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 642 | |
Radek Krejci | 334ccc7 | 2019-06-12 13:49:29 +0200 | [diff] [blame] | 643 | if (!range) { |
| 644 | return; |
| 645 | } |
| 646 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 647 | ypr_open(ctx->out, flag); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 648 | ly_print_(ctx->out, "%*s%s \"", INDENT, (basetype == LY_TYPE_STRING || basetype == LY_TYPE_BINARY) ? "length" : "range"); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 649 | LY_ARRAY_FOR(range->parts, u) { |
| 650 | if (u > 0) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 651 | ly_print_(ctx->out, " | "); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 652 | } |
| 653 | if (range->parts[u].max_64 == range->parts[u].min_64) { |
| 654 | if (basetype <= LY_TYPE_STRING) { /* unsigned values */ |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 655 | ly_print_(ctx->out, "%" PRIu64, range->parts[u].max_u64); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 656 | } else { /* signed values */ |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 657 | ly_print_(ctx->out, "%" PRId64, range->parts[u].max_64); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 658 | } |
| 659 | } else { |
| 660 | if (basetype <= LY_TYPE_STRING) { /* unsigned values */ |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 661 | ly_print_(ctx->out, "%" PRIu64 "..%" PRIu64, range->parts[u].min_u64, range->parts[u].max_u64); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 662 | } else { /* signed values */ |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 663 | ly_print_(ctx->out, "%" PRId64 "..%" PRId64, range->parts[u].min_64, range->parts[u].max_64); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 664 | } |
| 665 | } |
| 666 | } |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 667 | ly_print_(ctx->out, "\""); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 668 | |
| 669 | LEVEL++; |
| 670 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, range->exts, &inner_flag, 0); |
| 671 | if (range->emsg) { |
| 672 | ypr_open(ctx->out, &inner_flag); |
| 673 | ypr_substmt(ctx, LYEXT_SUBSTMT_ERRMSG, 0, range->emsg, range->exts); |
| 674 | } |
| 675 | if (range->eapptag) { |
| 676 | ypr_open(ctx->out, &inner_flag); |
| 677 | ypr_substmt(ctx, LYEXT_SUBSTMT_ERRTAG, 0, range->eapptag, range->exts); |
| 678 | } |
| 679 | ypr_description(ctx, range->dsc, range->exts, &inner_flag); |
| 680 | ypr_reference(ctx, range->ref, range->exts, &inner_flag); |
| 681 | |
| 682 | LEVEL--; |
| 683 | ypr_close(ctx, inner_flag); |
| 684 | } |
| 685 | |
| 686 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 687 | yprc_pattern(struct ypr_ctx *ctx, const struct lysc_pattern *pattern, ly_bool *flag) |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 688 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 689 | ly_bool inner_flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 690 | |
| 691 | ypr_open(ctx->out, flag); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 692 | ly_print_(ctx->out, "%*spattern \"", INDENT); |
Radek Krejci | 5457946 | 2019-04-30 12:47:06 +0200 | [diff] [blame] | 693 | ypr_encode(ctx->out, pattern->expr, -1); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 694 | ly_print_(ctx->out, "\""); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 695 | |
| 696 | LEVEL++; |
| 697 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, pattern->exts, &inner_flag, 0); |
| 698 | if (pattern->inverted) { |
| 699 | /* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */ |
| 700 | ypr_open(ctx->out, &inner_flag); |
| 701 | ypr_substmt(ctx, LYEXT_SUBSTMT_MODIFIER, 0, "invert-match", pattern->exts); |
| 702 | } |
| 703 | if (pattern->emsg) { |
| 704 | ypr_open(ctx->out, &inner_flag); |
| 705 | ypr_substmt(ctx, LYEXT_SUBSTMT_ERRMSG, 0, pattern->emsg, pattern->exts); |
| 706 | } |
| 707 | if (pattern->eapptag) { |
| 708 | ypr_open(ctx->out, &inner_flag); |
| 709 | ypr_substmt(ctx, LYEXT_SUBSTMT_ERRTAG, 0, pattern->eapptag, pattern->exts); |
| 710 | } |
| 711 | ypr_description(ctx, pattern->dsc, pattern->exts, &inner_flag); |
| 712 | ypr_reference(ctx, pattern->ref, pattern->exts, &inner_flag); |
| 713 | |
| 714 | LEVEL--; |
| 715 | ypr_close(ctx, inner_flag); |
| 716 | } |
| 717 | |
| 718 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 719 | yprp_when(struct ypr_ctx *ctx, struct lysp_when *when, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 720 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 721 | ly_bool inner_flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 722 | |
| 723 | if (!when) { |
| 724 | return; |
| 725 | } |
| 726 | ypr_open(ctx->out, flag); |
| 727 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 728 | ly_print_(ctx->out, "%*swhen \"", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 729 | ypr_encode(ctx->out, when->cond, -1); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 730 | ly_print_(ctx->out, "\""); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 731 | |
| 732 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 733 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, when->exts, &inner_flag, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 734 | ypr_description(ctx, when->dsc, when->exts, &inner_flag); |
| 735 | ypr_reference(ctx, when->ref, when->exts, &inner_flag); |
| 736 | LEVEL--; |
| 737 | ypr_close(ctx, inner_flag); |
| 738 | } |
| 739 | |
| 740 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 741 | yprc_when(struct ypr_ctx *ctx, struct lysc_when *when, ly_bool *flag) |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 742 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 743 | ly_bool inner_flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 744 | |
| 745 | if (!when) { |
| 746 | return; |
| 747 | } |
| 748 | ypr_open(ctx->out, flag); |
| 749 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 750 | ly_print_(ctx->out, "%*swhen \"", INDENT); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 751 | ypr_encode(ctx->out, when->cond->expr, -1); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 752 | ly_print_(ctx->out, "\""); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 753 | |
| 754 | LEVEL++; |
| 755 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, when->exts, &inner_flag, 0); |
| 756 | ypr_description(ctx, when->dsc, when->exts, &inner_flag); |
| 757 | ypr_reference(ctx, when->ref, when->exts, &inner_flag); |
| 758 | LEVEL--; |
| 759 | ypr_close(ctx, inner_flag); |
| 760 | } |
| 761 | |
| 762 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 763 | yprp_enum(struct ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 764 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 765 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 766 | ly_bool inner_flag; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 767 | |
| 768 | LY_ARRAY_FOR(items, u) { |
| 769 | ypr_open(ctx->out, flag); |
Radek Krejci | 7871ce5 | 2019-06-11 16:44:56 +0200 | [diff] [blame] | 770 | if (type == LY_TYPE_BITS) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 771 | ly_print_(ctx->out, "%*sbit %s", INDENT, items[u].name); |
Radek Krejci | 7871ce5 | 2019-06-11 16:44:56 +0200 | [diff] [blame] | 772 | } else { /* LY_TYPE_ENUM */ |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 773 | ly_print_(ctx->out, "%*senum \"", INDENT); |
Radek Krejci | 7871ce5 | 2019-06-11 16:44:56 +0200 | [diff] [blame] | 774 | ypr_encode(ctx->out, items[u].name, -1); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 775 | ly_print_(ctx->out, "\""); |
Radek Krejci | 7871ce5 | 2019-06-11 16:44:56 +0200 | [diff] [blame] | 776 | } |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 777 | inner_flag = 0; |
| 778 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 779 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, items[u].exts, &inner_flag, 0); |
| 780 | yprp_iffeatures(ctx, items[u].iffeatures, items[u].exts, &inner_flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 781 | if (items[u].flags & LYS_SET_VALUE) { |
| 782 | if (type == LY_TYPE_BITS) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 783 | ypr_unsigned(ctx, LYEXT_SUBSTMT_POSITION, 0, items[u].exts, items[u].value, &inner_flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 784 | } else { /* LY_TYPE_ENUM */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 785 | ypr_signed(ctx, LYEXT_SUBSTMT_VALUE, 0, items[u].exts, items[u].value, &inner_flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 786 | } |
| 787 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 788 | ypr_status(ctx, items[u].flags, items[u].exts, &inner_flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 789 | ypr_description(ctx, items[u].dsc, items[u].exts, &inner_flag); |
| 790 | ypr_reference(ctx, items[u].ref, items[u].exts, &inner_flag); |
| 791 | LEVEL--; |
| 792 | ypr_close(ctx, inner_flag); |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 797 | yprp_type(struct ypr_ctx *ctx, const struct lysp_type *type) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 798 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 799 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 800 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 801 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 802 | ly_print_(ctx->out, "%*stype %s", INDENT, type->name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 803 | LEVEL++; |
| 804 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 805 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, type->exts, &flag, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 806 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 807 | yprp_restr(ctx, type->range, "range", &flag); |
| 808 | yprp_restr(ctx, type->length, "length", &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 809 | LY_ARRAY_FOR(type->patterns, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 810 | yprp_restr(ctx, &type->patterns[u], "pattern", &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 811 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 812 | yprp_enum(ctx, type->bits, LY_TYPE_BITS, &flag); |
| 813 | yprp_enum(ctx, type->enums, LY_TYPE_ENUM, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 814 | |
| 815 | if (type->path) { |
| 816 | ypr_open(ctx->out, &flag); |
Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 817 | ypr_substmt(ctx, LYEXT_SUBSTMT_PATH, 0, type->path->expr, type->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 818 | } |
| 819 | if (type->flags & LYS_SET_REQINST) { |
| 820 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 821 | ypr_substmt(ctx, LYEXT_SUBSTMT_REQINSTANCE, 0, type->require_instance ? "true" : "false", type->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 822 | } |
| 823 | if (type->flags & LYS_SET_FRDIGITS) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 824 | ypr_unsigned(ctx, LYEXT_SUBSTMT_FRACDIGITS, 0, type->exts, type->fraction_digits, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 825 | } |
| 826 | LY_ARRAY_FOR(type->bases, u) { |
| 827 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 828 | ypr_substmt(ctx, LYEXT_SUBSTMT_BASE, u, type->bases[u], type->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 829 | } |
| 830 | LY_ARRAY_FOR(type->types, u) { |
| 831 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 832 | yprp_type(ctx, &type->types[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | LEVEL--; |
| 836 | ypr_close(ctx, flag); |
| 837 | } |
| 838 | |
| 839 | static void |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 840 | yprc_dflt_value(struct ypr_ctx *ctx, const struct lyd_value *value, struct lysc_ext_instance *exts) |
Radek Krejci | a191122 | 2019-07-22 17:24:50 +0200 | [diff] [blame] | 841 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 842 | ly_bool dynamic; |
Radek Krejci | a191122 | 2019-07-22 17:24:50 +0200 | [diff] [blame] | 843 | const char *str; |
| 844 | |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 845 | str = value->realtype->plugin->print(value, LY_PREF_JSON, NULL, &dynamic); |
Radek Krejci | a191122 | 2019-07-22 17:24:50 +0200 | [diff] [blame] | 846 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, str, exts); |
| 847 | if (dynamic) { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 848 | free((void *)str); |
Radek Krejci | a191122 | 2019-07-22 17:24:50 +0200 | [diff] [blame] | 849 | } |
| 850 | } |
| 851 | |
| 852 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 853 | yprc_type(struct ypr_ctx *ctx, const struct lysc_type *type) |
| 854 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 855 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 856 | ly_bool flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 857 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 858 | ly_print_(ctx->out, "%*stype %s", INDENT, lys_datatype2str(type->basetype)); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 859 | LEVEL++; |
| 860 | |
| 861 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, type->exts, &flag, 0); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 862 | |
Michal Vasko | 2bb55bc | 2020-08-05 13:27:04 +0200 | [diff] [blame] | 863 | switch (type->basetype) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 864 | case LY_TYPE_BINARY: { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 865 | struct lysc_type_bin *bin = (struct lysc_type_bin *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 866 | yprc_range(ctx, bin->length, type->basetype, &flag); |
| 867 | break; |
| 868 | } |
| 869 | case LY_TYPE_UINT8: |
| 870 | case LY_TYPE_UINT16: |
| 871 | case LY_TYPE_UINT32: |
| 872 | case LY_TYPE_UINT64: |
| 873 | case LY_TYPE_INT8: |
| 874 | case LY_TYPE_INT16: |
| 875 | case LY_TYPE_INT32: |
| 876 | case LY_TYPE_INT64: { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 877 | struct lysc_type_num *num = (struct lysc_type_num *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 878 | yprc_range(ctx, num->range, type->basetype, &flag); |
| 879 | break; |
| 880 | } |
| 881 | case LY_TYPE_STRING: { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 882 | struct lysc_type_str *str = (struct lysc_type_str *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 883 | yprc_range(ctx, str->length, type->basetype, &flag); |
| 884 | LY_ARRAY_FOR(str->patterns, u) { |
| 885 | yprc_pattern(ctx, str->patterns[u], &flag); |
| 886 | } |
| 887 | break; |
| 888 | } |
| 889 | case LY_TYPE_BITS: |
| 890 | case LY_TYPE_ENUM: { |
| 891 | /* bits and enums structures are compatible */ |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 892 | struct lysc_type_bits *bits = (struct lysc_type_bits *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 893 | LY_ARRAY_FOR(bits->bits, u) { |
| 894 | struct lysc_type_bitenum_item *item = &bits->bits[u]; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 895 | ly_bool inner_flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 896 | |
| 897 | ypr_open(ctx->out, &flag); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 898 | ly_print_(ctx->out, "%*s%s \"", INDENT, type->basetype == LY_TYPE_BITS ? "bit" : "enum"); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 899 | ypr_encode(ctx->out, item->name, -1); |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 900 | ly_print_(ctx->out, "\""); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 901 | LEVEL++; |
| 902 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, item->exts, &inner_flag, 0); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 903 | if (type->basetype == LY_TYPE_BITS) { |
| 904 | ypr_unsigned(ctx, LYEXT_SUBSTMT_POSITION, 0, item->exts, item->position, &inner_flag); |
| 905 | } else { /* LY_TYPE_ENUM */ |
| 906 | ypr_signed(ctx, LYEXT_SUBSTMT_VALUE, 0, item->exts, item->value, &inner_flag); |
| 907 | } |
| 908 | ypr_status(ctx, item->flags, item->exts, &inner_flag); |
| 909 | ypr_description(ctx, item->dsc, item->exts, &inner_flag); |
| 910 | ypr_reference(ctx, item->ref, item->exts, &inner_flag); |
| 911 | LEVEL--; |
| 912 | ypr_close(ctx, inner_flag); |
| 913 | } |
| 914 | break; |
| 915 | } |
| 916 | case LY_TYPE_BOOL: |
| 917 | case LY_TYPE_EMPTY: |
| 918 | /* nothing to do */ |
| 919 | break; |
| 920 | case LY_TYPE_DEC64: { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 921 | struct lysc_type_dec *dec = (struct lysc_type_dec *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 922 | ypr_open(ctx->out, &flag); |
| 923 | ypr_unsigned(ctx, LYEXT_SUBSTMT_FRACDIGITS, 0, type->exts, dec->fraction_digits, &flag); |
| 924 | yprc_range(ctx, dec->range, dec->basetype, &flag); |
| 925 | break; |
| 926 | } |
| 927 | case LY_TYPE_IDENT: { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 928 | struct lysc_type_identityref *ident = (struct lysc_type_identityref *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 929 | LY_ARRAY_FOR(ident->bases, u) { |
| 930 | ypr_open(ctx->out, &flag); |
| 931 | ypr_substmt(ctx, LYEXT_SUBSTMT_BASE, u, ident->bases[u]->name, type->exts); |
| 932 | } |
| 933 | break; |
| 934 | } |
| 935 | case LY_TYPE_INST: { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 936 | struct lysc_type_instanceid *inst = (struct lysc_type_instanceid *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 937 | ypr_open(ctx->out, &flag); |
| 938 | ypr_substmt(ctx, LYEXT_SUBSTMT_REQINSTANCE, 0, inst->require_instance ? "true" : "false", inst->exts); |
| 939 | break; |
| 940 | } |
| 941 | case LY_TYPE_LEAFREF: { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 942 | struct lysc_type_leafref *lr = (struct lysc_type_leafref *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 943 | ypr_open(ctx->out, &flag); |
Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 944 | ypr_substmt(ctx, LYEXT_SUBSTMT_PATH, 0, lr->path->expr, lr->exts); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 945 | ypr_substmt(ctx, LYEXT_SUBSTMT_REQINSTANCE, 0, lr->require_instance ? "true" : "false", lr->exts); |
| 946 | yprc_type(ctx, lr->realtype); |
| 947 | break; |
| 948 | } |
| 949 | case LY_TYPE_UNION: { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 950 | struct lysc_type_union *un = (struct lysc_type_union *)type; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 951 | LY_ARRAY_FOR(un->types, u) { |
| 952 | ypr_open(ctx->out, &flag); |
| 953 | yprc_type(ctx, un->types[u]); |
| 954 | } |
| 955 | break; |
| 956 | } |
| 957 | default: |
| 958 | LOGINT(ctx->module->ctx); |
| 959 | } |
| 960 | |
| 961 | LEVEL--; |
| 962 | ypr_close(ctx, flag); |
| 963 | } |
| 964 | |
| 965 | static void |
| 966 | yprp_typedef(struct ypr_ctx *ctx, const struct lysp_tpdf *tpdf) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 967 | { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 968 | ly_print_(ctx->out, "\n%*stypedef %s {\n", INDENT, tpdf->name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 969 | LEVEL++; |
| 970 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 971 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, tpdf->exts, NULL, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 972 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 973 | yprp_type(ctx, &tpdf->type); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 974 | |
| 975 | if (tpdf->units) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 976 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, tpdf->units, tpdf->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 977 | } |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 978 | if (tpdf->dflt.str) { |
| 979 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 980 | } |
| 981 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 982 | ypr_status(ctx, tpdf->flags, tpdf->exts, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 983 | ypr_description(ctx, tpdf->dsc, tpdf->exts, NULL); |
| 984 | ypr_reference(ctx, tpdf->ref, tpdf->exts, NULL); |
| 985 | |
| 986 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 987 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 988 | } |
| 989 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 990 | static void yprp_node(struct ypr_ctx *ctx, const struct lysp_node *node); |
| 991 | static void yprc_node(struct ypr_ctx *ctx, const struct lysc_node *node); |
| 992 | static void yprp_action(struct ypr_ctx *ctx, const struct lysp_action *action); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 993 | |
| 994 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 995 | yprp_grouping(struct ypr_ctx *ctx, const struct lysp_grp *grp) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 996 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 997 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 998 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 999 | struct lysp_node *data; |
| 1000 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1001 | ly_print_(ctx->out, "\n%*sgrouping %s", INDENT, grp->name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1002 | LEVEL++; |
| 1003 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1004 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, grp->exts, &flag, 0); |
| 1005 | ypr_status(ctx, grp->flags, grp->exts, &flag); |
Radek Krejci | fc81ea8 | 2019-04-18 13:27:22 +0200 | [diff] [blame] | 1006 | ypr_description(ctx, grp->dsc, grp->exts, &flag); |
| 1007 | ypr_reference(ctx, grp->ref, grp->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1008 | |
| 1009 | LY_ARRAY_FOR(grp->typedefs, u) { |
Radek Krejci | 59edcf7 | 2019-05-02 09:53:17 +0200 | [diff] [blame] | 1010 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1011 | yprp_typedef(ctx, &grp->typedefs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | LY_ARRAY_FOR(grp->groupings, u) { |
Radek Krejci | 59edcf7 | 2019-05-02 09:53:17 +0200 | [diff] [blame] | 1015 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1016 | yprp_grouping(ctx, &grp->groupings[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | LY_LIST_FOR(grp->data, data) { |
Radek Krejci | fc81ea8 | 2019-04-18 13:27:22 +0200 | [diff] [blame] | 1020 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1021 | yprp_node(ctx, data); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | LY_ARRAY_FOR(grp->actions, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1025 | yprp_action(ctx, &grp->actions[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1026 | } |
| 1027 | |
| 1028 | LEVEL--; |
| 1029 | ypr_close(ctx, flag); |
| 1030 | } |
| 1031 | |
| 1032 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1033 | yprp_inout(struct ypr_ctx *ctx, const struct lysp_action_inout *inout, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1034 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1035 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1036 | struct lysp_node *data; |
| 1037 | |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 1038 | if (!inout->data) { |
| 1039 | /* no children */ |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1040 | return; |
| 1041 | } |
| 1042 | ypr_open(ctx->out, flag); |
| 1043 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1044 | ly_print_(ctx->out, "\n%*s%s {\n", INDENT, (inout->nodetype == LYS_INPUT ? "input" : "output")); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1045 | LEVEL++; |
| 1046 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1047 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, inout->exts, NULL, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1048 | LY_ARRAY_FOR(inout->musts, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1049 | yprp_restr(ctx, &inout->musts[u], "must", NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1050 | } |
| 1051 | LY_ARRAY_FOR(inout->typedefs, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1052 | yprp_typedef(ctx, &inout->typedefs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1053 | } |
| 1054 | LY_ARRAY_FOR(inout->groupings, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1055 | yprp_grouping(ctx, &inout->groupings[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | LY_LIST_FOR(inout->data, data) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1059 | yprp_node(ctx, data); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | LEVEL--; |
| 1063 | ypr_close(ctx, 1); |
| 1064 | } |
| 1065 | |
| 1066 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1067 | yprc_inout(struct ypr_ctx *ctx, const struct lysc_action *action, const struct lysc_action_inout *inout, ly_bool *flag) |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1068 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1069 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1070 | struct lysc_node *data; |
| 1071 | |
| 1072 | if (!inout->data) { |
| 1073 | /* input/output is empty */ |
| 1074 | return; |
| 1075 | } |
| 1076 | ypr_open(ctx->out, flag); |
| 1077 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1078 | ly_print_(ctx->out, "\n%*s%s {\n", INDENT, (&action->input == inout) ? "input" : "output"); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1079 | LEVEL++; |
| 1080 | |
| 1081 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, (&action->input == inout) ? action->input_exts : action->output_exts, NULL, 0); |
| 1082 | LY_ARRAY_FOR(inout->musts, u) { |
| 1083 | yprc_must(ctx, &inout->musts[u], NULL); |
| 1084 | } |
| 1085 | |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 1086 | if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1087 | LY_LIST_FOR(inout->data, data) { |
| 1088 | yprc_node(ctx, data); |
| 1089 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | LEVEL--; |
| 1093 | ypr_close(ctx, 1); |
| 1094 | } |
| 1095 | |
| 1096 | static void |
| 1097 | yprp_notification(struct ypr_ctx *ctx, const struct lysp_notif *notif) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1098 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1099 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1100 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1101 | struct lysp_node *data; |
| 1102 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1103 | ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1104 | |
| 1105 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1106 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, notif->exts, &flag, 0); |
| 1107 | yprp_iffeatures(ctx, notif->iffeatures, notif->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1108 | |
| 1109 | LY_ARRAY_FOR(notif->musts, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1110 | yprp_restr(ctx, ¬if->musts[u], "must", &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1111 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1112 | ypr_status(ctx, notif->flags, notif->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1113 | ypr_description(ctx, notif->dsc, notif->exts, &flag); |
| 1114 | ypr_reference(ctx, notif->ref, notif->exts, &flag); |
| 1115 | |
| 1116 | LY_ARRAY_FOR(notif->typedefs, u) { |
| 1117 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1118 | yprp_typedef(ctx, ¬if->typedefs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | LY_ARRAY_FOR(notif->groupings, u) { |
| 1122 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1123 | yprp_grouping(ctx, ¬if->groupings[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | LY_LIST_FOR(notif->data, data) { |
| 1127 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1128 | yprp_node(ctx, data); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1129 | } |
| 1130 | |
| 1131 | LEVEL--; |
| 1132 | ypr_close(ctx, flag); |
| 1133 | } |
| 1134 | |
| 1135 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1136 | yprc_notification(struct ypr_ctx *ctx, const struct lysc_notif *notif) |
| 1137 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1138 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1139 | ly_bool flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1140 | struct lysc_node *data; |
| 1141 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1142 | ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1143 | |
| 1144 | LEVEL++; |
| 1145 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, notif->exts, &flag, 0); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1146 | |
| 1147 | LY_ARRAY_FOR(notif->musts, u) { |
| 1148 | yprc_must(ctx, ¬if->musts[u], &flag); |
| 1149 | } |
| 1150 | ypr_status(ctx, notif->flags, notif->exts, &flag); |
| 1151 | ypr_description(ctx, notif->dsc, notif->exts, &flag); |
| 1152 | ypr_reference(ctx, notif->ref, notif->exts, &flag); |
| 1153 | |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 1154 | if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1155 | LY_LIST_FOR(notif->data, data) { |
| 1156 | ypr_open(ctx->out, &flag); |
| 1157 | yprc_node(ctx, data); |
| 1158 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | LEVEL--; |
| 1162 | ypr_close(ctx, flag); |
| 1163 | } |
| 1164 | |
| 1165 | static void |
| 1166 | yprp_action(struct ypr_ctx *ctx, const struct lysp_action *action) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1167 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1168 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1169 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1170 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1171 | ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1172 | |
| 1173 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1174 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, action->exts, &flag, 0); |
| 1175 | yprp_iffeatures(ctx, action->iffeatures, action->exts, &flag); |
| 1176 | ypr_status(ctx, action->flags, action->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1177 | ypr_description(ctx, action->dsc, action->exts, &flag); |
| 1178 | ypr_reference(ctx, action->ref, action->exts, &flag); |
| 1179 | |
| 1180 | LY_ARRAY_FOR(action->typedefs, u) { |
| 1181 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1182 | yprp_typedef(ctx, &action->typedefs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | LY_ARRAY_FOR(action->groupings, u) { |
| 1186 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1187 | yprp_grouping(ctx, &action->groupings[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1188 | } |
| 1189 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1190 | yprp_inout(ctx, &action->input, &flag); |
| 1191 | yprp_inout(ctx, &action->output, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1192 | |
| 1193 | LEVEL--; |
| 1194 | ypr_close(ctx, flag); |
| 1195 | } |
| 1196 | |
| 1197 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1198 | yprc_action(struct ypr_ctx *ctx, const struct lysc_action *action) |
| 1199 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1200 | ly_bool flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1201 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1202 | ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1203 | |
| 1204 | LEVEL++; |
| 1205 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, action->exts, &flag, 0); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1206 | ypr_status(ctx, action->flags, action->exts, &flag); |
| 1207 | ypr_description(ctx, action->dsc, action->exts, &flag); |
| 1208 | ypr_reference(ctx, action->ref, action->exts, &flag); |
| 1209 | |
| 1210 | yprc_inout(ctx, action, &action->input, &flag); |
| 1211 | yprc_inout(ctx, action, &action->output, &flag); |
| 1212 | |
| 1213 | LEVEL--; |
| 1214 | ypr_close(ctx, flag); |
| 1215 | } |
| 1216 | |
| 1217 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1218 | yprp_node_common1(struct ypr_ctx *ctx, const struct lysp_node *node, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1219 | { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1220 | ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1221 | LEVEL++; |
| 1222 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1223 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, node->exts, flag, 0); |
| 1224 | yprp_when(ctx, node->when, flag); |
| 1225 | yprp_iffeatures(ctx, node->iffeatures, node->exts, flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1226 | } |
| 1227 | |
| 1228 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1229 | yprc_node_common1(struct ypr_ctx *ctx, const struct lysc_node *node, ly_bool *flag) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1230 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1231 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1232 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1233 | ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n"); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1234 | LEVEL++; |
| 1235 | |
| 1236 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, node->exts, flag, 0); |
| 1237 | LY_ARRAY_FOR(node->when, u) { |
| 1238 | yprc_when(ctx, node->when[u], flag); |
| 1239 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1240 | } |
| 1241 | |
| 1242 | /* macr oto unify the code */ |
| 1243 | #define YPR_NODE_COMMON2 \ |
| 1244 | ypr_config(ctx, node->flags, node->exts, flag); \ |
| 1245 | if (node->nodetype & (LYS_CHOICE | LYS_LEAF | LYS_ANYDATA)) { \ |
| 1246 | ypr_mandatory(ctx, node->flags, node->exts, flag); \ |
| 1247 | } \ |
| 1248 | ypr_status(ctx, node->flags, node->exts, flag); \ |
| 1249 | ypr_description(ctx, node->dsc, node->exts, flag); \ |
| 1250 | ypr_reference(ctx, node->ref, node->exts, flag) |
| 1251 | |
| 1252 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1253 | yprp_node_common2(struct ypr_ctx *ctx, const struct lysp_node *node, ly_bool *flag) |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1254 | { |
| 1255 | YPR_NODE_COMMON2; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1256 | } |
| 1257 | |
| 1258 | static void |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1259 | yprc_node_common2(struct ypr_ctx *ctx, const struct lysc_node *node, ly_bool *flag) |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1260 | { |
| 1261 | YPR_NODE_COMMON2; |
| 1262 | } |
| 1263 | |
| 1264 | #undef YPR_NODE_COMMON2 |
| 1265 | |
| 1266 | static void |
| 1267 | yprp_container(struct ypr_ctx *ctx, const struct lysp_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1268 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1269 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1270 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1271 | struct lysp_node *child; |
| 1272 | struct lysp_node_container *cont = (struct lysp_node_container *)node; |
| 1273 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1274 | yprp_node_common1(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1275 | |
| 1276 | LY_ARRAY_FOR(cont->musts, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1277 | yprp_restr(ctx, &cont->musts[u], "must", &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1278 | } |
| 1279 | if (cont->presence) { |
| 1280 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1281 | ypr_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, cont->presence, cont->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1282 | } |
| 1283 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1284 | yprp_node_common2(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1285 | |
| 1286 | LY_ARRAY_FOR(cont->typedefs, u) { |
| 1287 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1288 | yprp_typedef(ctx, &cont->typedefs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1289 | } |
| 1290 | |
| 1291 | LY_ARRAY_FOR(cont->groupings, u) { |
| 1292 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1293 | yprp_grouping(ctx, &cont->groupings[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1294 | } |
| 1295 | |
| 1296 | LY_LIST_FOR(cont->child, child) { |
| 1297 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1298 | yprp_node(ctx, child); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | LY_ARRAY_FOR(cont->actions, u) { |
| 1302 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1303 | yprp_action(ctx, &cont->actions[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1304 | } |
| 1305 | |
| 1306 | LY_ARRAY_FOR(cont->notifs, u) { |
| 1307 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1308 | yprp_notification(ctx, &cont->notifs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | LEVEL--; |
| 1312 | ypr_close(ctx, flag); |
| 1313 | } |
| 1314 | |
| 1315 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1316 | yprc_container(struct ypr_ctx *ctx, const struct lysc_node *node) |
| 1317 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1318 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1319 | ly_bool flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1320 | struct lysc_node *child; |
| 1321 | struct lysc_node_container *cont = (struct lysc_node_container *)node; |
| 1322 | |
| 1323 | yprc_node_common1(ctx, node, &flag); |
| 1324 | |
| 1325 | LY_ARRAY_FOR(cont->musts, u) { |
| 1326 | yprc_must(ctx, &cont->musts[u], &flag); |
| 1327 | } |
| 1328 | if (cont->flags & LYS_PRESENCE) { |
| 1329 | ypr_open(ctx->out, &flag); |
| 1330 | ypr_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, "true", cont->exts); |
| 1331 | } |
| 1332 | |
| 1333 | yprc_node_common2(ctx, node, &flag); |
| 1334 | |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 1335 | if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1336 | LY_LIST_FOR(cont->child, child) { |
| 1337 | ypr_open(ctx->out, &flag); |
| 1338 | yprc_node(ctx, child); |
| 1339 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1340 | |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1341 | LY_ARRAY_FOR(cont->actions, u) { |
| 1342 | ypr_open(ctx->out, &flag); |
| 1343 | yprc_action(ctx, &cont->actions[u]); |
| 1344 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1345 | |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1346 | LY_ARRAY_FOR(cont->notifs, u) { |
| 1347 | ypr_open(ctx->out, &flag); |
| 1348 | yprc_notification(ctx, &cont->notifs[u]); |
| 1349 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1350 | } |
| 1351 | |
| 1352 | LEVEL--; |
| 1353 | ypr_close(ctx, flag); |
| 1354 | } |
| 1355 | |
| 1356 | static void |
| 1357 | yprp_case(struct ypr_ctx *ctx, const struct lysp_node *node) |
| 1358 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1359 | ly_bool flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1360 | struct lysp_node *child; |
| 1361 | struct lysp_node_case *cas = (struct lysp_node_case *)node; |
| 1362 | |
| 1363 | yprp_node_common1(ctx, node, &flag); |
| 1364 | yprp_node_common2(ctx, node, &flag); |
| 1365 | |
| 1366 | LY_LIST_FOR(cas->child, child) { |
| 1367 | ypr_open(ctx->out, &flag); |
| 1368 | yprp_node(ctx, child); |
| 1369 | } |
| 1370 | |
| 1371 | LEVEL--; |
| 1372 | ypr_close(ctx, flag); |
| 1373 | } |
| 1374 | |
| 1375 | static void |
| 1376 | yprc_case(struct ypr_ctx *ctx, const struct lysc_node_case *cs) |
| 1377 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1378 | ly_bool flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1379 | struct lysc_node *child; |
| 1380 | |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 1381 | yprc_node_common1(ctx, (struct lysc_node *)cs, &flag); |
| 1382 | yprc_node_common2(ctx, (struct lysc_node *)cs, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1383 | |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 1384 | if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 1385 | for (child = cs->child; child && child->parent == (struct lysc_node *)cs; child = child->next) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1386 | ypr_open(ctx->out, &flag); |
| 1387 | yprc_node(ctx, child); |
| 1388 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | LEVEL--; |
| 1392 | ypr_close(ctx, flag); |
| 1393 | } |
| 1394 | |
| 1395 | static void |
| 1396 | yprp_choice(struct ypr_ctx *ctx, const struct lysp_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1397 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1398 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1399 | struct lysp_node *child; |
| 1400 | struct lysp_node_choice *choice = (struct lysp_node_choice *)node; |
| 1401 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1402 | yprp_node_common1(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1403 | |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 1404 | if (choice->dflt.str) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1405 | ypr_open(ctx->out, &flag); |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 1406 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, choice->dflt.str, choice->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1407 | } |
| 1408 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1409 | yprp_node_common2(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1410 | |
| 1411 | LY_LIST_FOR(choice->child, child) { |
| 1412 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1413 | yprp_node(ctx, child); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1414 | } |
| 1415 | |
| 1416 | LEVEL--; |
| 1417 | ypr_close(ctx, flag); |
| 1418 | } |
| 1419 | |
| 1420 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1421 | yprc_choice(struct ypr_ctx *ctx, const struct lysc_node *node) |
| 1422 | { |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1423 | ly_bool flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1424 | struct lysc_node_case *cs; |
| 1425 | struct lysc_node_choice *choice = (struct lysc_node_choice *)node; |
| 1426 | |
| 1427 | yprc_node_common1(ctx, node, &flag); |
| 1428 | |
| 1429 | if (choice->dflt) { |
| 1430 | ypr_open(ctx->out, &flag); |
| 1431 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, choice->dflt->name, choice->exts); |
| 1432 | } |
| 1433 | |
| 1434 | yprc_node_common2(ctx, node, &flag); |
| 1435 | |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 1436 | for (cs = choice->cases; cs; cs = (struct lysc_node_case *)cs->next) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1437 | ypr_open(ctx->out, &flag); |
| 1438 | yprc_case(ctx, cs); |
| 1439 | } |
| 1440 | |
| 1441 | LEVEL--; |
| 1442 | ypr_close(ctx, flag); |
| 1443 | } |
| 1444 | |
| 1445 | static void |
| 1446 | yprp_leaf(struct ypr_ctx *ctx, const struct lysp_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1447 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1448 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1449 | struct lysp_node_leaf *leaf = (struct lysp_node_leaf *)node; |
| 1450 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1451 | yprp_node_common1(ctx, node, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1452 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1453 | yprp_type(ctx, &leaf->type); |
| 1454 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, leaf->units, leaf->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1455 | LY_ARRAY_FOR(leaf->musts, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1456 | yprp_restr(ctx, &leaf->musts[u], "must", NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1457 | } |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 1458 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, leaf->dflt.str, leaf->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1459 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1460 | yprp_node_common2(ctx, node, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1461 | |
| 1462 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1463 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1464 | } |
| 1465 | |
| 1466 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1467 | yprc_leaf(struct ypr_ctx *ctx, const struct lysc_node *node) |
| 1468 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1469 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1470 | struct lysc_node_leaf *leaf = (struct lysc_node_leaf *)node; |
| 1471 | |
| 1472 | yprc_node_common1(ctx, node, NULL); |
| 1473 | |
| 1474 | yprc_type(ctx, leaf->type); |
| 1475 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, leaf->units, leaf->exts); |
| 1476 | LY_ARRAY_FOR(leaf->musts, u) { |
| 1477 | yprc_must(ctx, &leaf->musts[u], NULL); |
| 1478 | } |
Radek Krejci | a191122 | 2019-07-22 17:24:50 +0200 | [diff] [blame] | 1479 | |
| 1480 | if (leaf->dflt) { |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 1481 | yprc_dflt_value(ctx, leaf->dflt, leaf->exts); |
Radek Krejci | a191122 | 2019-07-22 17:24:50 +0200 | [diff] [blame] | 1482 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1483 | |
| 1484 | yprc_node_common2(ctx, node, NULL); |
| 1485 | |
| 1486 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1487 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1488 | } |
| 1489 | |
| 1490 | static void |
| 1491 | yprp_leaflist(struct ypr_ctx *ctx, const struct lysp_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1492 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1493 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1494 | struct lysp_node_leaflist *llist = (struct lysp_node_leaflist *)node; |
| 1495 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1496 | yprp_node_common1(ctx, node, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1497 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1498 | yprp_type(ctx, &llist->type); |
| 1499 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, llist->units, llist->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1500 | LY_ARRAY_FOR(llist->musts, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1501 | yprp_restr(ctx, &llist->musts[u], "must", NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1502 | } |
| 1503 | LY_ARRAY_FOR(llist->dflts, u) { |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 1504 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, llist->dflts[u].str, llist->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1505 | } |
| 1506 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1507 | ypr_config(ctx, node->flags, node->exts, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1508 | |
| 1509 | if (llist->flags & LYS_SET_MIN) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1510 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, llist->exts, llist->min, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1511 | } |
| 1512 | if (llist->flags & LYS_SET_MAX) { |
| 1513 | if (llist->max) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1514 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, llist->exts, llist->max, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1515 | } else { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1516 | ypr_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", llist->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1517 | } |
| 1518 | } |
| 1519 | |
| 1520 | if (llist->flags & LYS_ORDBY_MASK) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1521 | ypr_substmt(ctx, LYEXT_SUBSTMT_ORDEREDBY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1522 | } |
| 1523 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1524 | ypr_status(ctx, node->flags, node->exts, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1525 | ypr_description(ctx, node->dsc, node->exts, NULL); |
| 1526 | ypr_reference(ctx, node->ref, node->exts, NULL); |
| 1527 | |
| 1528 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1529 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1530 | } |
| 1531 | |
| 1532 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1533 | yprc_leaflist(struct ypr_ctx *ctx, const struct lysc_node *node) |
| 1534 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1535 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1536 | struct lysc_node_leaflist *llist = (struct lysc_node_leaflist *)node; |
| 1537 | |
| 1538 | yprc_node_common1(ctx, node, NULL); |
| 1539 | |
| 1540 | yprc_type(ctx, llist->type); |
| 1541 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, llist->units, llist->exts); |
| 1542 | LY_ARRAY_FOR(llist->musts, u) { |
| 1543 | yprc_must(ctx, &llist->musts[u], NULL); |
| 1544 | } |
| 1545 | LY_ARRAY_FOR(llist->dflts, u) { |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 1546 | yprc_dflt_value(ctx, llist->dflts[u], llist->exts); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1547 | } |
| 1548 | |
| 1549 | ypr_config(ctx, node->flags, node->exts, NULL); |
| 1550 | |
| 1551 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, llist->exts, llist->min, NULL); |
| 1552 | if (llist->max) { |
| 1553 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, llist->exts, llist->max, NULL); |
| 1554 | } else { |
| 1555 | ypr_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", llist->exts); |
| 1556 | } |
| 1557 | |
| 1558 | ypr_substmt(ctx, LYEXT_SUBSTMT_ORDEREDBY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts); |
| 1559 | |
| 1560 | ypr_status(ctx, node->flags, node->exts, NULL); |
| 1561 | ypr_description(ctx, node->dsc, node->exts, NULL); |
| 1562 | ypr_reference(ctx, node->ref, node->exts, NULL); |
| 1563 | |
| 1564 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1565 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1566 | } |
| 1567 | |
| 1568 | static void |
| 1569 | yprp_list(struct ypr_ctx *ctx, const struct lysp_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1570 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1571 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1572 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1573 | struct lysp_node *child; |
| 1574 | struct lysp_node_list *list = (struct lysp_node_list *)node; |
| 1575 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1576 | yprp_node_common1(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1577 | |
| 1578 | LY_ARRAY_FOR(list->musts, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1579 | yprp_restr(ctx, &list->musts[u], "must", NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1580 | } |
| 1581 | if (list->key) { |
| 1582 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1583 | ypr_substmt(ctx, LYEXT_SUBSTMT_KEY, 0, list->key, list->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1584 | } |
| 1585 | LY_ARRAY_FOR(list->uniques, u) { |
| 1586 | ypr_open(ctx->out, &flag); |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 1587 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, list->uniques[u].str, list->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1588 | } |
| 1589 | |
Michal Vasko | acb8e74 | 2020-10-20 10:28:02 +0200 | [diff] [blame] | 1590 | ypr_config(ctx, node->flags, node->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1591 | |
| 1592 | if (list->flags & LYS_SET_MIN) { |
Michal Vasko | acb8e74 | 2020-10-20 10:28:02 +0200 | [diff] [blame] | 1593 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, list->exts, list->min, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1594 | } |
| 1595 | if (list->flags & LYS_SET_MAX) { |
| 1596 | if (list->max) { |
Michal Vasko | acb8e74 | 2020-10-20 10:28:02 +0200 | [diff] [blame] | 1597 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, list->exts, list->max, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1598 | } else { |
Michal Vasko | acb8e74 | 2020-10-20 10:28:02 +0200 | [diff] [blame] | 1599 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1600 | ypr_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", list->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | if (list->flags & LYS_ORDBY_MASK) { |
Michal Vasko | acb8e74 | 2020-10-20 10:28:02 +0200 | [diff] [blame] | 1605 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1606 | ypr_substmt(ctx, LYEXT_SUBSTMT_ORDEREDBY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1607 | } |
| 1608 | |
Michal Vasko | acb8e74 | 2020-10-20 10:28:02 +0200 | [diff] [blame] | 1609 | ypr_status(ctx, node->flags, node->exts, &flag); |
| 1610 | ypr_description(ctx, node->dsc, node->exts, &flag); |
| 1611 | ypr_reference(ctx, node->ref, node->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1612 | |
| 1613 | LY_ARRAY_FOR(list->typedefs, u) { |
| 1614 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1615 | yprp_typedef(ctx, &list->typedefs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1616 | } |
| 1617 | |
| 1618 | LY_ARRAY_FOR(list->groupings, u) { |
| 1619 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1620 | yprp_grouping(ctx, &list->groupings[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1621 | } |
| 1622 | |
| 1623 | LY_LIST_FOR(list->child, child) { |
| 1624 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1625 | yprp_node(ctx, child); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1626 | } |
| 1627 | |
| 1628 | LY_ARRAY_FOR(list->actions, u) { |
| 1629 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1630 | yprp_action(ctx, &list->actions[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1631 | } |
| 1632 | |
| 1633 | LY_ARRAY_FOR(list->notifs, u) { |
| 1634 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1635 | yprp_notification(ctx, &list->notifs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1636 | } |
| 1637 | |
| 1638 | LEVEL--; |
| 1639 | ypr_close(ctx, flag); |
| 1640 | } |
| 1641 | |
| 1642 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1643 | yprc_list(struct ypr_ctx *ctx, const struct lysc_node *node) |
| 1644 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1645 | LY_ARRAY_COUNT_TYPE u, v; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1646 | struct lysc_node *child; |
| 1647 | struct lysc_node_list *list = (struct lysc_node_list *)node; |
| 1648 | |
Michal Vasko | acb8e74 | 2020-10-20 10:28:02 +0200 | [diff] [blame] | 1649 | yprc_node_common1(ctx, node, NULL); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1650 | |
| 1651 | LY_ARRAY_FOR(list->musts, u) { |
| 1652 | yprc_must(ctx, &list->musts[u], NULL); |
| 1653 | } |
Radek Krejci | 0fe9b51 | 2019-07-26 17:51:05 +0200 | [diff] [blame] | 1654 | if (!(list->flags & LYS_KEYLESS)) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1655 | ly_print_(ctx->out, "%*skey \"", INDENT); |
Radek Krejci | 0fe9b51 | 2019-07-26 17:51:05 +0200 | [diff] [blame] | 1656 | for (struct lysc_node *key = list->child; key && key->nodetype == LYS_LEAF && (key->flags & LYS_KEY); key = key->next) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1657 | ly_print_(ctx->out, "%s%s", u > 0 ? ", " : "", key->name); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1658 | } |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1659 | ly_print_(ctx->out, "\";\n"); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1660 | } |
| 1661 | LY_ARRAY_FOR(list->uniques, u) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1662 | ly_print_(ctx->out, "%*sunique \"", INDENT); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1663 | LY_ARRAY_FOR(list->uniques[u], v) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1664 | ly_print_(ctx->out, "%s%s", v > 0 ? ", " : "", list->uniques[u][v]->name); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1665 | } |
| 1666 | ypr_close(ctx, 0); |
| 1667 | } |
| 1668 | |
| 1669 | ypr_config(ctx, node->flags, node->exts, NULL); |
| 1670 | |
| 1671 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, list->exts, list->min, NULL); |
| 1672 | if (list->max) { |
| 1673 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, list->exts, list->max, NULL); |
| 1674 | } else { |
| 1675 | ypr_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", list->exts); |
| 1676 | } |
| 1677 | |
| 1678 | ypr_substmt(ctx, LYEXT_SUBSTMT_ORDEREDBY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts); |
| 1679 | |
| 1680 | ypr_status(ctx, node->flags, node->exts, NULL); |
| 1681 | ypr_description(ctx, node->dsc, node->exts, NULL); |
| 1682 | ypr_reference(ctx, node->ref, node->exts, NULL); |
| 1683 | |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 1684 | if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1685 | LY_LIST_FOR(list->child, child) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1686 | yprc_node(ctx, child); |
| 1687 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1688 | |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1689 | LY_ARRAY_FOR(list->actions, u) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1690 | yprc_action(ctx, &list->actions[u]); |
| 1691 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1692 | |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1693 | LY_ARRAY_FOR(list->notifs, u) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 1694 | yprc_notification(ctx, &list->notifs[u]); |
| 1695 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1696 | } |
| 1697 | |
| 1698 | LEVEL--; |
Michal Vasko | acb8e74 | 2020-10-20 10:28:02 +0200 | [diff] [blame] | 1699 | ypr_close(ctx, 1); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1700 | } |
| 1701 | |
| 1702 | static void |
| 1703 | yprp_refine(struct ypr_ctx *ctx, struct lysp_refine *refine) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1704 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1705 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1706 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1707 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1708 | ly_print_(ctx->out, "%*srefine \"%s\"", INDENT, refine->nodeid); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1709 | LEVEL++; |
| 1710 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1711 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, refine->exts, &flag, 0); |
| 1712 | yprp_iffeatures(ctx, refine->iffeatures, refine->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1713 | |
| 1714 | LY_ARRAY_FOR(refine->musts, u) { |
| 1715 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1716 | yprp_restr(ctx, &refine->musts[u], "must", NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1717 | } |
| 1718 | |
| 1719 | if (refine->presence) { |
| 1720 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1721 | ypr_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, refine->presence, refine->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1722 | } |
| 1723 | |
| 1724 | LY_ARRAY_FOR(refine->dflts, u) { |
| 1725 | ypr_open(ctx->out, &flag); |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1726 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, refine->dflts[u].str, refine->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1727 | } |
| 1728 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1729 | ypr_config(ctx, refine->flags, refine->exts, &flag); |
| 1730 | ypr_mandatory(ctx, refine->flags, refine->exts, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1731 | |
| 1732 | if (refine->flags & LYS_SET_MIN) { |
| 1733 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1734 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, refine->exts, refine->min, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1735 | } |
| 1736 | if (refine->flags & LYS_SET_MAX) { |
| 1737 | ypr_open(ctx->out, &flag); |
| 1738 | if (refine->max) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1739 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, refine->exts, refine->max, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1740 | } else { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1741 | ypr_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", refine->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1742 | } |
| 1743 | } |
| 1744 | |
| 1745 | ypr_description(ctx, refine->dsc, refine->exts, &flag); |
| 1746 | ypr_reference(ctx, refine->ref, refine->exts, &flag); |
| 1747 | |
| 1748 | LEVEL--; |
| 1749 | ypr_close(ctx, flag); |
| 1750 | } |
| 1751 | |
| 1752 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1753 | yprp_augment(struct ypr_ctx *ctx, const struct lysp_augment *aug) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1754 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1755 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1756 | struct lysp_node *child; |
| 1757 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1758 | ly_print_(ctx->out, "%*saugment \"%s\" {\n", INDENT, aug->nodeid); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1759 | LEVEL++; |
| 1760 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1761 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, aug->exts, NULL, 0); |
| 1762 | yprp_when(ctx, aug->when, NULL); |
| 1763 | yprp_iffeatures(ctx, aug->iffeatures, aug->exts, NULL); |
| 1764 | ypr_status(ctx, aug->flags, aug->exts, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1765 | ypr_description(ctx, aug->dsc, aug->exts, NULL); |
| 1766 | ypr_reference(ctx, aug->ref, aug->exts, NULL); |
| 1767 | |
| 1768 | LY_LIST_FOR(aug->child, child) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1769 | yprp_node(ctx, child); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1770 | } |
| 1771 | |
| 1772 | LY_ARRAY_FOR(aug->actions, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1773 | yprp_action(ctx, &aug->actions[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1774 | } |
| 1775 | |
| 1776 | LY_ARRAY_FOR(aug->notifs, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1777 | yprp_notification(ctx, &aug->notifs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1778 | } |
| 1779 | |
| 1780 | LEVEL--; |
Radek Krejci | fc81ea8 | 2019-04-18 13:27:22 +0200 | [diff] [blame] | 1781 | ypr_close(ctx, 1); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1782 | } |
| 1783 | |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1784 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1785 | yprp_uses(struct ypr_ctx *ctx, const struct lysp_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1786 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1787 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1788 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1789 | struct lysp_node_uses *uses = (struct lysp_node_uses *)node; |
| 1790 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1791 | yprp_node_common1(ctx, node, &flag); |
| 1792 | yprp_node_common2(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1793 | |
| 1794 | LY_ARRAY_FOR(uses->refines, u) { |
| 1795 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1796 | yprp_refine(ctx, &uses->refines[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1797 | } |
| 1798 | |
| 1799 | LY_ARRAY_FOR(uses->augments, u) { |
| 1800 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1801 | yprp_augment(ctx, &uses->augments[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1802 | } |
| 1803 | |
| 1804 | LEVEL--; |
| 1805 | ypr_close(ctx, flag); |
| 1806 | } |
| 1807 | |
| 1808 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1809 | yprp_anydata(struct ypr_ctx *ctx, const struct lysp_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1810 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1811 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1812 | ly_bool flag = 0; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1813 | struct lysp_node_anydata *any = (struct lysp_node_anydata *)node; |
| 1814 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1815 | yprp_node_common1(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1816 | |
| 1817 | LY_ARRAY_FOR(any->musts, u) { |
| 1818 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1819 | yprp_restr(ctx, &any->musts[u], "must", NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1820 | } |
| 1821 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1822 | yprp_node_common2(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1823 | |
| 1824 | LEVEL--; |
| 1825 | ypr_close(ctx, flag); |
| 1826 | } |
| 1827 | |
| 1828 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1829 | yprc_anydata(struct ypr_ctx *ctx, const struct lysc_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1830 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1831 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 1832 | ly_bool flag = 0; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1833 | struct lysc_node_anydata *any = (struct lysc_node_anydata *)node; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1834 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1835 | yprc_node_common1(ctx, node, &flag); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1836 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1837 | LY_ARRAY_FOR(any->musts, u) { |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1838 | ypr_open(ctx->out, &flag); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1839 | yprc_must(ctx, &any->musts[u], NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1840 | } |
| 1841 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1842 | yprc_node_common2(ctx, node, &flag); |
| 1843 | |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1844 | LEVEL--; |
| 1845 | ypr_close(ctx, flag); |
| 1846 | } |
| 1847 | |
| 1848 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1849 | yprp_node(struct ypr_ctx *ctx, const struct lysp_node *node) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1850 | { |
| 1851 | switch (node->nodetype) { |
| 1852 | case LYS_CONTAINER: |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1853 | yprp_container(ctx, node); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1854 | break; |
| 1855 | case LYS_CHOICE: |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1856 | yprp_choice(ctx, node); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1857 | break; |
| 1858 | case LYS_LEAF: |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1859 | yprp_leaf(ctx, node); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1860 | break; |
| 1861 | case LYS_LEAFLIST: |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1862 | yprp_leaflist(ctx, node); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1863 | break; |
| 1864 | case LYS_LIST: |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1865 | yprp_list(ctx, node); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1866 | break; |
| 1867 | case LYS_USES: |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1868 | yprp_uses(ctx, node); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1869 | break; |
| 1870 | case LYS_ANYXML: |
| 1871 | case LYS_ANYDATA: |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1872 | yprp_anydata(ctx, node); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1873 | break; |
| 1874 | case LYS_CASE: |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1875 | yprp_case(ctx, node); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1876 | break; |
| 1877 | default: |
| 1878 | break; |
| 1879 | } |
| 1880 | } |
| 1881 | |
| 1882 | static void |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1883 | yprc_node(struct ypr_ctx *ctx, const struct lysc_node *node) |
| 1884 | { |
| 1885 | switch (node->nodetype) { |
| 1886 | case LYS_CONTAINER: |
| 1887 | yprc_container(ctx, node); |
| 1888 | break; |
| 1889 | case LYS_CHOICE: |
| 1890 | yprc_choice(ctx, node); |
| 1891 | break; |
| 1892 | case LYS_LEAF: |
| 1893 | yprc_leaf(ctx, node); |
| 1894 | break; |
| 1895 | case LYS_LEAFLIST: |
| 1896 | yprc_leaflist(ctx, node); |
| 1897 | break; |
| 1898 | case LYS_LIST: |
| 1899 | yprc_list(ctx, node); |
| 1900 | break; |
| 1901 | case LYS_ANYXML: |
| 1902 | case LYS_ANYDATA: |
| 1903 | yprc_anydata(ctx, node); |
| 1904 | break; |
| 1905 | default: |
| 1906 | break; |
| 1907 | } |
| 1908 | } |
| 1909 | |
| 1910 | static void |
| 1911 | yprp_deviation(struct ypr_ctx *ctx, const struct lysp_deviation *deviation) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1912 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 1913 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1914 | struct lysp_deviate_add *add; |
| 1915 | struct lysp_deviate_rpl *rpl; |
| 1916 | struct lysp_deviate_del *del; |
fredgan | 2b11ddb | 2019-10-21 11:03:39 +0800 | [diff] [blame] | 1917 | struct lysp_deviate *elem; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1918 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1919 | ly_print_(ctx->out, "%*sdeviation \"%s\" {\n", INDENT, deviation->nodeid); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1920 | LEVEL++; |
| 1921 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1922 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, deviation->exts, NULL, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1923 | ypr_description(ctx, deviation->dsc, deviation->exts, NULL); |
| 1924 | ypr_reference(ctx, deviation->ref, deviation->exts, NULL); |
| 1925 | |
fredgan | 2b11ddb | 2019-10-21 11:03:39 +0800 | [diff] [blame] | 1926 | LY_LIST_FOR(deviation->deviates, elem) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1927 | ly_print_(ctx->out, "%*sdeviate ", INDENT); |
fredgan | 2b11ddb | 2019-10-21 11:03:39 +0800 | [diff] [blame] | 1928 | if (elem->mod == LYS_DEV_NOT_SUPPORTED) { |
| 1929 | if (elem->exts) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1930 | ly_print_(ctx->out, "not-supported {\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1931 | LEVEL++; |
| 1932 | |
fredgan | 2b11ddb | 2019-10-21 11:03:39 +0800 | [diff] [blame] | 1933 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, elem->exts, NULL, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1934 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1935 | ly_print_(ctx->out, "not-supported;\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1936 | continue; |
| 1937 | } |
fredgan | 2b11ddb | 2019-10-21 11:03:39 +0800 | [diff] [blame] | 1938 | } else if (elem->mod == LYS_DEV_ADD) { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 1939 | add = (struct lysp_deviate_add *)elem; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1940 | ly_print_(ctx->out, "add {\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1941 | LEVEL++; |
| 1942 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1943 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, add->exts, NULL, 0); |
| 1944 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, add->units, add->exts); |
Radek Krejci | 7eb54ba | 2020-05-18 16:30:04 +0200 | [diff] [blame] | 1945 | LY_ARRAY_FOR(add->musts, u) { |
| 1946 | yprp_restr(ctx, &add->musts[u], "must", NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1947 | } |
Radek Krejci | 7eb54ba | 2020-05-18 16:30:04 +0200 | [diff] [blame] | 1948 | LY_ARRAY_FOR(add->uniques, u) { |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1949 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, add->uniques[u].str, add->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1950 | } |
Radek Krejci | 7eb54ba | 2020-05-18 16:30:04 +0200 | [diff] [blame] | 1951 | LY_ARRAY_FOR(add->dflts, u) { |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1952 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, add->dflts[u].str, add->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1953 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1954 | ypr_config(ctx, add->flags, add->exts, NULL); |
| 1955 | ypr_mandatory(ctx, add->flags, add->exts, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1956 | if (add->flags & LYS_SET_MIN) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1957 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, add->exts, add->min, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1958 | } |
| 1959 | if (add->flags & LYS_SET_MAX) { |
| 1960 | if (add->max) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1961 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, add->exts, add->max, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1962 | } else { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1963 | ypr_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", add->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1964 | } |
| 1965 | } |
fredgan | 2b11ddb | 2019-10-21 11:03:39 +0800 | [diff] [blame] | 1966 | } else if (elem->mod == LYS_DEV_REPLACE) { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 1967 | rpl = (struct lysp_deviate_rpl *)elem; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1968 | ly_print_(ctx->out, "replace {\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1969 | LEVEL++; |
| 1970 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1971 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, rpl->exts, NULL, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1972 | if (rpl->type) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1973 | yprp_type(ctx, rpl->type); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1974 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1975 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, rpl->units, rpl->exts); |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1976 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, rpl->dflt.str, rpl->exts); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1977 | ypr_config(ctx, rpl->flags, rpl->exts, NULL); |
| 1978 | ypr_mandatory(ctx, rpl->flags, rpl->exts, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1979 | if (rpl->flags & LYS_SET_MIN) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1980 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN, 0, rpl->exts, rpl->min, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1981 | } |
| 1982 | if (rpl->flags & LYS_SET_MAX) { |
| 1983 | if (rpl->max) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1984 | ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX, 0, rpl->exts, rpl->max, NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1985 | } else { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1986 | ypr_substmt(ctx, LYEXT_SUBSTMT_MAX, 0, "unbounded", rpl->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1987 | } |
| 1988 | } |
fredgan | 2b11ddb | 2019-10-21 11:03:39 +0800 | [diff] [blame] | 1989 | } else if (elem->mod == LYS_DEV_DELETE) { |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 1990 | del = (struct lysp_deviate_del *)elem; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 1991 | ly_print_(ctx->out, "delete {\n"); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1992 | LEVEL++; |
| 1993 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1994 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, del->exts, NULL, 0); |
| 1995 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, del->units, del->exts); |
Radek Krejci | 7eb54ba | 2020-05-18 16:30:04 +0200 | [diff] [blame] | 1996 | LY_ARRAY_FOR(del->musts, u) { |
| 1997 | yprp_restr(ctx, &del->musts[u], "must", NULL); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 1998 | } |
Radek Krejci | 7eb54ba | 2020-05-18 16:30:04 +0200 | [diff] [blame] | 1999 | LY_ARRAY_FOR(del->uniques, u) { |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 2000 | ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, del->uniques[u].str, del->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2001 | } |
Radek Krejci | 7eb54ba | 2020-05-18 16:30:04 +0200 | [diff] [blame] | 2002 | LY_ARRAY_FOR(del->dflts, u) { |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 2003 | ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, del->dflts[u].str, del->exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2004 | } |
| 2005 | } |
| 2006 | |
| 2007 | LEVEL--; |
| 2008 | ypr_close(ctx, 1); |
| 2009 | } |
| 2010 | |
| 2011 | LEVEL--; |
| 2012 | ypr_close(ctx, 1); |
| 2013 | } |
| 2014 | |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2015 | static void |
| 2016 | yang_print_parsed_linkage(struct ypr_ctx *ctx, const struct lysp_module *modp) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2017 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 2018 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2019 | |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2020 | LY_ARRAY_FOR(modp->imports, u) { |
Michal Vasko | 3e9bc2f | 2020-11-04 17:13:56 +0100 | [diff] [blame] | 2021 | if (modp->imports[u].flags & LYS_INTERNAL) { |
| 2022 | continue; |
| 2023 | } |
| 2024 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2025 | ly_print_(ctx->out, "%s%*simport %s {\n", u ? "" : "\n", INDENT, modp->imports[u].name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2026 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2027 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->imports[u].exts, NULL, 0); |
| 2028 | ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2029 | if (modp->imports[u].rev[0]) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2030 | ypr_substmt(ctx, LYEXT_SUBSTMT_REVISIONDATE, 0, modp->imports[u].rev, modp->imports[u].exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2031 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2032 | ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts); |
| 2033 | ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2034 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2035 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2036 | } |
| 2037 | LY_ARRAY_FOR(modp->includes, u) { |
| 2038 | if (modp->includes[u].rev[0] || modp->includes[u].dsc || modp->includes[u].ref || modp->includes[u].exts) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2039 | ly_print_(ctx->out, "%s%*sinclude %s {\n", u ? "" : "\n", INDENT, modp->includes[u].name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2040 | LEVEL++; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2041 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->includes[u].exts, NULL, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2042 | if (modp->includes[u].rev[0]) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2043 | ypr_substmt(ctx, LYEXT_SUBSTMT_REVISIONDATE, 0, modp->includes[u].rev, modp->includes[u].exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2044 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2045 | ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts); |
| 2046 | ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2047 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2048 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2049 | } else { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2050 | ly_print_(ctx->out, "\n%*sinclude \"%s\";\n", INDENT, modp->includes[u].name); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2051 | } |
| 2052 | } |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2053 | } |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2054 | |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2055 | static void |
| 2056 | yang_print_parsed_body(struct ypr_ctx *ctx, const struct lysp_module *modp) |
| 2057 | { |
| 2058 | LY_ARRAY_COUNT_TYPE u; |
| 2059 | struct lysp_node *data; |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2060 | |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2061 | LY_ARRAY_FOR(modp->extensions, u) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2062 | ly_print_(ctx->out, "\n"); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2063 | yprp_extension(ctx, &modp->extensions[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2064 | } |
| 2065 | if (modp->exts) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2066 | ly_print_(ctx->out, "\n"); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2067 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->exts, NULL, 0); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2068 | } |
| 2069 | |
| 2070 | LY_ARRAY_FOR(modp->features, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2071 | yprp_feature(ctx, &modp->features[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2072 | } |
| 2073 | |
| 2074 | LY_ARRAY_FOR(modp->identities, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2075 | yprp_identity(ctx, &modp->identities[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2076 | } |
| 2077 | |
| 2078 | LY_ARRAY_FOR(modp->typedefs, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2079 | yprp_typedef(ctx, &modp->typedefs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2080 | } |
| 2081 | |
| 2082 | LY_ARRAY_FOR(modp->groupings, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2083 | yprp_grouping(ctx, &modp->groupings[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2084 | } |
| 2085 | |
| 2086 | LY_LIST_FOR(modp->data, data) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2087 | yprp_node(ctx, data); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2088 | } |
| 2089 | |
| 2090 | LY_ARRAY_FOR(modp->augments, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2091 | yprp_augment(ctx, &modp->augments[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2092 | } |
| 2093 | |
| 2094 | LY_ARRAY_FOR(modp->rpcs, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2095 | yprp_action(ctx, &modp->rpcs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2096 | } |
| 2097 | |
| 2098 | LY_ARRAY_FOR(modp->notifs, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2099 | yprp_notification(ctx, &modp->notifs[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2100 | } |
| 2101 | |
| 2102 | LY_ARRAY_FOR(modp->deviations, u) { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2103 | yprp_deviation(ctx, &modp->deviations[u]); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2104 | } |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2105 | } |
| 2106 | |
| 2107 | LY_ERR |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 2108 | yang_print_parsed_module(struct ly_out *out, const struct lys_module *module, const struct lysp_module *modp, uint32_t options) |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2109 | { |
| 2110 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 2111 | struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .schema = YPR_PARSED, .options = options}, *ctx = &ctx_; |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2112 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2113 | ly_print_(ctx->out, "%*smodule %s {\n", INDENT, module->name); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2114 | LEVEL++; |
| 2115 | |
| 2116 | /* module-header-stmts */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 2117 | if (modp->version) { |
| 2118 | ypr_substmt(ctx, LYEXT_SUBSTMT_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2119 | } |
| 2120 | |
| 2121 | ypr_substmt(ctx, LYEXT_SUBSTMT_NAMESPACE, 0, module->ns, modp->exts); |
| 2122 | ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, module->prefix, modp->exts); |
| 2123 | |
| 2124 | /* linkage-stmts (import/include) */ |
| 2125 | yang_print_parsed_linkage(ctx, modp); |
| 2126 | |
| 2127 | /* meta-stmts */ |
| 2128 | if (module->org || module->contact || module->dsc || module->ref) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2129 | ly_print_(out, "\n"); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2130 | } |
| 2131 | ypr_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, module->org, modp->exts); |
| 2132 | ypr_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, module->contact, modp->exts); |
| 2133 | ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, module->dsc, modp->exts); |
| 2134 | ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, module->ref, modp->exts); |
| 2135 | |
| 2136 | /* revision-stmts */ |
| 2137 | if (modp->revs) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2138 | ly_print_(out, "\n"); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2139 | } |
| 2140 | LY_ARRAY_FOR(modp->revs, u) { |
| 2141 | yprp_revision(ctx, &modp->revs[u]); |
| 2142 | } |
| 2143 | /* body-stmts */ |
| 2144 | yang_print_parsed_body(ctx, modp); |
| 2145 | |
| 2146 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2147 | ly_print_(out, "%*s}\n", INDENT); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2148 | ly_print_flush(out); |
| 2149 | |
| 2150 | return LY_SUCCESS; |
| 2151 | } |
| 2152 | |
| 2153 | static void |
| 2154 | yprp_belongsto(struct ypr_ctx *ctx, const struct lysp_submodule *submodp) |
| 2155 | { |
Michal Vasko | c3781c3 | 2020-10-06 14:04:08 +0200 | [diff] [blame] | 2156 | ly_print_(ctx->out, "%*sbelongs-to %s {\n", INDENT, submodp->mod->name); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2157 | LEVEL++; |
| 2158 | yprp_extension_instances(ctx, LYEXT_SUBSTMT_BELONGSTO, 0, submodp->exts, NULL, 0); |
| 2159 | ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, submodp->prefix, submodp->exts); |
| 2160 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2161 | ly_print_(ctx->out, "%*s}\n", INDENT); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2162 | } |
| 2163 | |
| 2164 | LY_ERR |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 2165 | yang_print_parsed_submodule(struct ly_out *out, const struct lys_module *module, const struct lysp_submodule *submodp, uint32_t options) |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2166 | { |
| 2167 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 2168 | struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .schema = YPR_PARSED, .options = options}, *ctx = &ctx_; |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2169 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2170 | ly_print_(ctx->out, "%*ssubmodule %s {\n", INDENT, submodp->name); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2171 | LEVEL++; |
| 2172 | |
| 2173 | /* submodule-header-stmts */ |
| 2174 | if (submodp->version) { |
| 2175 | ypr_substmt(ctx, LYEXT_SUBSTMT_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts); |
| 2176 | } |
| 2177 | |
| 2178 | yprp_belongsto(ctx, submodp); |
| 2179 | |
| 2180 | /* linkage-stmts (import/include) */ |
| 2181 | yang_print_parsed_linkage(ctx, (struct lysp_module *)submodp); |
| 2182 | |
| 2183 | /* meta-stmts */ |
| 2184 | if (submodp->org || submodp->contact || submodp->dsc || submodp->ref) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2185 | ly_print_(out, "\n"); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2186 | } |
| 2187 | ypr_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, submodp->org, submodp->exts); |
| 2188 | ypr_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, submodp->contact, submodp->exts); |
| 2189 | ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, submodp->dsc, submodp->exts); |
| 2190 | ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, submodp->ref, submodp->exts); |
| 2191 | |
| 2192 | /* revision-stmts */ |
| 2193 | if (submodp->revs) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2194 | ly_print_(out, "\n"); |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2195 | } |
| 2196 | LY_ARRAY_FOR(submodp->revs, u) { |
| 2197 | yprp_revision(ctx, &submodp->revs[u]); |
| 2198 | } |
| 2199 | /* body-stmts */ |
| 2200 | yang_print_parsed_body(ctx, (struct lysp_module *)submodp); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2201 | |
| 2202 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2203 | ly_print_(out, "%*s}\n", INDENT); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2204 | ly_print_flush(out); |
| 2205 | |
| 2206 | return LY_SUCCESS; |
| 2207 | } |
| 2208 | |
| 2209 | LY_ERR |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 2210 | yang_print_compiled_node(struct ly_out *out, const struct lysc_node *node, uint32_t options) |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 2211 | { |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 2212 | struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = node->module, .options = options}, *ctx = &ctx_; |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 2213 | |
| 2214 | yprc_node(ctx, node); |
| 2215 | |
| 2216 | ly_print_flush(out); |
| 2217 | return LY_SUCCESS; |
| 2218 | } |
| 2219 | |
| 2220 | LY_ERR |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 2221 | yang_print_compiled(struct ly_out *out, const struct lys_module *module, uint32_t options) |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2222 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 2223 | LY_ARRAY_COUNT_TYPE u; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2224 | struct lysc_node *data; |
| 2225 | struct lysc_module *modc = module->compiled; |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 2226 | struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .options = options}, *ctx = &ctx_; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2227 | |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2228 | ly_print_(ctx->out, "%*smodule %s {\n", INDENT, module->name); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2229 | LEVEL++; |
| 2230 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2231 | /* module-header-stmts */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2232 | ypr_substmt(ctx, LYEXT_SUBSTMT_NAMESPACE, 0, module->ns, modc->exts); |
| 2233 | ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, module->prefix, modc->exts); |
| 2234 | |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 2235 | /* no linkage-stmts */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2236 | |
| 2237 | /* meta-stmts */ |
| 2238 | if (module->org || module->contact || module->dsc || module->ref) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2239 | ly_print_(out, "\n"); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2240 | } |
| 2241 | ypr_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, module->org, modc->exts); |
| 2242 | ypr_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, module->contact, modc->exts); |
| 2243 | ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, module->dsc, modc->exts); |
| 2244 | ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, module->ref, modc->exts); |
| 2245 | |
| 2246 | /* revision-stmts */ |
| 2247 | if (module->revision) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2248 | ly_print_(ctx->out, "\n%*srevision %s;\n", INDENT, module->revision); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2249 | } |
| 2250 | |
| 2251 | /* body-stmts */ |
| 2252 | if (modc->exts) { |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2253 | ly_print_(out, "\n"); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2254 | yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, module->compiled->exts, NULL, 0); |
| 2255 | } |
| 2256 | |
Radek Krejci | 80d281e | 2020-09-14 17:42:54 +0200 | [diff] [blame] | 2257 | LY_ARRAY_FOR(module->identities, u) { |
| 2258 | yprc_identity(ctx, &module->identities[u]); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2259 | } |
| 2260 | |
Radek Krejci | 52f6555 | 2020-09-01 17:03:35 +0200 | [diff] [blame] | 2261 | if (!(ctx->options & LYS_PRINT_NO_SUBSTMT)) { |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 2262 | LY_LIST_FOR(modc->data, data) { |
| 2263 | yprc_node(ctx, data); |
| 2264 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2265 | |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 2266 | LY_ARRAY_FOR(modc->rpcs, u) { |
| 2267 | yprc_action(ctx, &modc->rpcs[u]); |
| 2268 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2269 | |
Radek Krejci | d8c0f5e | 2019-11-17 12:18:34 +0800 | [diff] [blame] | 2270 | LY_ARRAY_FOR(modc->notifs, u) { |
| 2271 | yprc_notification(ctx, &modc->notifs[u]); |
| 2272 | } |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | LEVEL--; |
Michal Vasko | 5233e96 | 2020-08-14 14:26:20 +0200 | [diff] [blame] | 2276 | ly_print_(out, "%*s}\n", INDENT); |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 2277 | ly_print_flush(out); |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 2278 | |
| 2279 | return LY_SUCCESS; |
| 2280 | } |