Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1 | /** |
Radek Krejci | efdd0ce | 2015-05-26 16:48:29 +0200 | [diff] [blame] | 2 | * @file printer/yang.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
Radek Krejci | efdd0ce | 2015-05-26 16:48:29 +0200 | [diff] [blame] | 4 | * @brief YANG printer for libyang data model structure |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 5 | * |
| 6 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in |
| 15 | * the documentation and/or other materials provided with the |
| 16 | * distribution. |
| 17 | * 3. Neither the name of the Company nor the names of its contributors |
| 18 | * may be used to endorse or promote products derived from this |
| 19 | * software without specific prior written permission. |
| 20 | */ |
| 21 | |
| 22 | #include <stdlib.h> |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 23 | #include <string.h> |
| 24 | |
Radek Krejci | 998a0b8 | 2015-08-17 13:14:36 +0200 | [diff] [blame] | 25 | #include "common.h" |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 26 | #include "printer.h" |
Michal Vasko | 2d162e1 | 2015-09-24 14:33:29 +0200 | [diff] [blame] | 27 | #include "tree_schema.h" |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 28 | |
| 29 | #define INDENT "" |
| 30 | #define LEVEL (level*2) |
| 31 | |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 32 | static void yang_print_snode(struct lyout *out, int level, const struct lys_node *node, int mask); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 33 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 34 | static void |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 35 | yang_print_open(struct lyout *out, int *flag) |
| 36 | { |
| 37 | if (flag && !*flag) { |
| 38 | *flag = 1; |
| 39 | ly_print(out, " {\n"); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | static void |
| 44 | yang_print_close(struct lyout *out, int level, int flag) |
| 45 | { |
| 46 | if (flag) { |
| 47 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
| 48 | } else { |
| 49 | ly_print(out, ";\n"); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | static void |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 54 | yang_print_text(struct lyout *out, int level, const char *name, const char *text, int singleline) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 55 | { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 56 | const char *s, *t; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 57 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 58 | if (singleline) { |
| 59 | ly_print(out, "%*s%s \"", LEVEL, INDENT, name); |
| 60 | } else { |
| 61 | ly_print(out, "%*s%s\n", LEVEL, INDENT, name); |
| 62 | level++; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 63 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 64 | ly_print(out, "%*s\"", LEVEL, INDENT); |
| 65 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 66 | t = text; |
| 67 | while ((s = strchr(t, '\n'))) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 68 | ly_write(out, t, (s - t) + 1); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 69 | t = s + 1; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 70 | ly_print(out, "%*s", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 71 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 72 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 73 | ly_print(out, "%s\";\n", t); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 74 | level--; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 75 | |
| 76 | } |
| 77 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 78 | static void |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 79 | yang_print_nacmext(struct lyout *out, int level, const struct lys_node *node, const struct lys_module *module, int *flag) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 80 | { |
Radek Krejci | 6764bb3 | 2015-07-03 15:16:04 +0200 | [diff] [blame] | 81 | int i, j; |
Radek Krejci | 86909d2 | 2015-07-03 16:11:25 +0200 | [diff] [blame] | 82 | const char *prefix = NULL; |
Radek Krejci | 6764bb3 | 2015-07-03 15:16:04 +0200 | [diff] [blame] | 83 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 84 | if (node->nacm && (!node->parent || node->parent->nacm != node->nacm)) { |
Radek Krejci | 6764bb3 | 2015-07-03 15:16:04 +0200 | [diff] [blame] | 85 | /* locate ietf-netconf-acm module in imports */ |
Michal Vasko | db7aa99 | 2015-07-08 09:37:38 +0200 | [diff] [blame] | 86 | if (!strcmp(module->name, "ietf-netconf-acm")) { |
| 87 | prefix = module->prefix; |
Radek Krejci | 6764bb3 | 2015-07-03 15:16:04 +0200 | [diff] [blame] | 88 | } else { |
| 89 | /* search in imports */ |
Michal Vasko | db7aa99 | 2015-07-08 09:37:38 +0200 | [diff] [blame] | 90 | for (i = 0; i < module->imp_size; i++) { |
| 91 | if (!strcmp(module->imp[i].module->name, "ietf-netconf-acm")) { |
| 92 | prefix = module->imp[i].prefix; |
Radek Krejci | 6764bb3 | 2015-07-03 15:16:04 +0200 | [diff] [blame] | 93 | break; |
| 94 | } |
| 95 | } |
| 96 | /* and in imports of includes */ |
| 97 | if (!prefix) { |
Michal Vasko | db7aa99 | 2015-07-08 09:37:38 +0200 | [diff] [blame] | 98 | for (j = 0; j < module->inc_size; j++) { |
| 99 | for (i = 0; i < module->inc[j].submodule->imp_size; i++) { |
| 100 | if (!strcmp(module->inc[j].submodule->imp[i].module->name, "ietf-netconf-acm")) { |
| 101 | prefix = module->inc[j].submodule->imp[i].prefix; |
Radek Krejci | 6764bb3 | 2015-07-03 15:16:04 +0200 | [diff] [blame] | 102 | break; |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 109 | if ((node->nacm & LYS_NACM_DENYW) && (!node->parent || !(node->parent->nacm & LYS_NACM_DENYW))) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 110 | yang_print_open(out, flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 111 | ly_print(out, "%*s%s:default-deny-write;\n", LEVEL, INDENT, prefix); |
Radek Krejci | 6764bb3 | 2015-07-03 15:16:04 +0200 | [diff] [blame] | 112 | } |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 113 | if ((node->nacm & LYS_NACM_DENYA) && (!node->parent || !(node->parent->nacm & LYS_NACM_DENYA))) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 114 | yang_print_open(out, flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 115 | ly_print(out, "%*s%s:default-deny-all;\n", LEVEL, INDENT, prefix); |
Radek Krejci | 6764bb3 | 2015-07-03 15:16:04 +0200 | [diff] [blame] | 116 | } |
| 117 | } |
Radek Krejci | 6a11385 | 2015-07-03 16:04:20 +0200 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /* |
| 121 | * Covers: |
| 122 | * description, reference, status |
| 123 | */ |
| 124 | static void |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 125 | yang_print_snode_common(struct lyout *out, int level, const struct lys_node *node, int *flag) |
Radek Krejci | 6a11385 | 2015-07-03 16:04:20 +0200 | [diff] [blame] | 126 | { |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 127 | if (node->flags & LYS_STATUS_CURR) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 128 | yang_print_open(out, flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 129 | ly_print(out, "%*sstatus \"current\";\n", LEVEL, INDENT); |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 130 | } else if (node->flags & LYS_STATUS_DEPRC) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 131 | yang_print_open(out, flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 132 | ly_print(out, "%*sstatus \"deprecated\";\n", LEVEL, INDENT); |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 133 | } else if (node->flags & LYS_STATUS_OBSLT) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 134 | yang_print_open(out, flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 135 | ly_print(out, "%*sstatus \"obsolete\";\n", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 136 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 137 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 138 | if (node->dsc) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 139 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 140 | yang_print_text(out, level, "description", node->dsc, 0); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 141 | } |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 142 | if (node->ref) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 143 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 144 | yang_print_text(out, level, "reference", node->ref, 0); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 145 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /* |
| 149 | * Covers: |
Michal Vasko | 2b8faed | 2015-06-09 12:51:20 +0200 | [diff] [blame] | 150 | * config, mandatory |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 151 | * description, reference, status |
| 152 | */ |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 153 | static void |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 154 | yang_print_snode_common2(struct lyout *out, int level, const struct lys_node *node, int *flag) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 155 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 156 | if (node->parent && (node->parent->flags & LYS_CONFIG_MASK) != (node->flags & LYS_CONFIG_MASK)) { |
| 157 | /* print config only when it differs from the parent */ |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 158 | if (node->flags & LYS_CONFIG_W) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 159 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 160 | ly_print(out, "%*sconfig true;\n", LEVEL, INDENT); |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 161 | } else if (node->flags & LYS_CONFIG_R) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 162 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 163 | ly_print(out, "%*sconfig false;\n", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 164 | } |
| 165 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 166 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 167 | if (node->flags & LYS_MAND_TRUE) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 168 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 169 | ly_print(out, "%*smandatory true;\n", LEVEL, INDENT); |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 170 | } else if (node->flags & LYS_MAND_FALSE) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 171 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 172 | ly_print(out, "%*smandatory false;\n", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 173 | } |
Michal Vasko | 2b8faed | 2015-06-09 12:51:20 +0200 | [diff] [blame] | 174 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 175 | yang_print_snode_common(out, level, node, flag); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 176 | } |
| 177 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 178 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 179 | yang_print_iffeature(struct lyout *out, int level, const struct lys_module *module, const struct lys_feature *feat) |
Michal Vasko | c39c4b1 | 2015-07-07 14:55:33 +0200 | [diff] [blame] | 180 | { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 181 | ly_print(out, "%*sif-feature ", LEVEL, INDENT); |
Michal Vasko | c39c4b1 | 2015-07-07 14:55:33 +0200 | [diff] [blame] | 182 | if ((feat->module != module) && !feat->module->type) { |
Michal Vasko | 2d851a9 | 2015-10-20 16:16:36 +0200 | [diff] [blame] | 183 | ly_print(out, "%s:", feat->module->name); |
Michal Vasko | c39c4b1 | 2015-07-07 14:55:33 +0200 | [diff] [blame] | 184 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 185 | ly_print(out, "%s;\n", feat->name); |
Michal Vasko | c39c4b1 | 2015-07-07 14:55:33 +0200 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 189 | yang_print_feature(struct lyout *out, int level, const struct lys_feature *feat) |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 190 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 191 | int i, flag = 0; |
Michal Vasko | 30f6e91 | 2015-07-07 12:24:27 +0200 | [diff] [blame] | 192 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 193 | ly_print(out, "%*sfeature %s", LEVEL, INDENT, feat->name); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 194 | level++; |
| 195 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 196 | yang_print_snode_common(out, level, (struct lys_node *)feat, &flag); |
Michal Vasko | 30f6e91 | 2015-07-07 12:24:27 +0200 | [diff] [blame] | 197 | for (i = 0; i < feat->features_size; ++i) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 198 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 199 | yang_print_iffeature(out, level, feat->module, feat->features[i]); |
Michal Vasko | 30f6e91 | 2015-07-07 12:24:27 +0200 | [diff] [blame] | 200 | } |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 201 | |
| 202 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 203 | yang_print_close(out, level, flag); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | static void |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 207 | yang_print_restr(struct lyout *out, int level, const struct lys_restr *restr, int *flag) |
Radek Krejci | 41726f9 | 2015-06-19 13:11:05 +0200 | [diff] [blame] | 208 | { |
Radek Krejci | 0bd5db4 | 2015-06-19 13:30:07 +0200 | [diff] [blame] | 209 | if (restr->dsc != NULL) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 210 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 211 | yang_print_text(out, level, "description", restr->dsc, 0); |
Radek Krejci | 41726f9 | 2015-06-19 13:11:05 +0200 | [diff] [blame] | 212 | } |
Radek Krejci | 0bd5db4 | 2015-06-19 13:30:07 +0200 | [diff] [blame] | 213 | if (restr->ref != NULL) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 214 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 215 | yang_print_text(out, level, "reference", restr->ref, 0); |
Radek Krejci | 41726f9 | 2015-06-19 13:11:05 +0200 | [diff] [blame] | 216 | } |
Radek Krejci | 0bd5db4 | 2015-06-19 13:30:07 +0200 | [diff] [blame] | 217 | if (restr->eapptag != NULL) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 218 | yang_print_open(out, flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 219 | ly_print(out, "%*serror-app-tag \"%s\";\n", LEVEL, INDENT, restr->eapptag); |
Radek Krejci | 41726f9 | 2015-06-19 13:11:05 +0200 | [diff] [blame] | 220 | } |
Radek Krejci | 0bd5db4 | 2015-06-19 13:30:07 +0200 | [diff] [blame] | 221 | if (restr->emsg != NULL) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 222 | yang_print_open(out, flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 223 | yang_print_text(out, level, "error-message", restr->emsg, 0); |
Radek Krejci | 41726f9 | 2015-06-19 13:11:05 +0200 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | |
| 227 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 228 | yang_print_when(struct lyout *out, int level, const struct lys_module *module, const struct lys_when *when) |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 229 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 230 | int flag = 0; |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 231 | const char *xml_expr; |
| 232 | |
Michal Vasko | fba1526 | 2015-10-21 12:10:28 +0200 | [diff] [blame] | 233 | xml_expr = transform_json2xml(module, when->cond, NULL, NULL, NULL); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 234 | if (!xml_expr) { |
| 235 | ly_print(out, "(!error!)"); |
| 236 | return; |
| 237 | } |
| 238 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 239 | ly_print(out, "%*swhen \"%s\"", LEVEL, INDENT, xml_expr); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 240 | lydict_remove(module->ctx, xml_expr); |
| 241 | |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 242 | level++; |
| 243 | if (when->dsc) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 244 | yang_print_open(out, &flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 245 | yang_print_text(out, level, "description", when->dsc, 0); |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 246 | } |
| 247 | if (when->ref) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 248 | yang_print_open(out, &flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 249 | yang_print_text(out, level, "reference", when->ref, 0); |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 250 | } |
| 251 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 252 | yang_print_close(out, level, flag); |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 256 | yang_print_type(struct lyout *out, int level, const struct lys_module *module, const struct lys_type *type) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 257 | { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 258 | int i; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 259 | int flag = 0, flag2; |
Michal Vasko | 0fb82c6 | 2015-10-20 13:41:53 +0200 | [diff] [blame] | 260 | const char *str; |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 261 | struct lys_module *mod; |
Radek Krejci | 25d782a | 2015-05-22 15:03:23 +0200 | [diff] [blame] | 262 | |
Michal Vasko | 0fb82c6 | 2015-10-20 13:41:53 +0200 | [diff] [blame] | 263 | if (type->module_name) { |
Michal Vasko | fba1526 | 2015-10-21 12:10:28 +0200 | [diff] [blame] | 264 | str = transform_json2xml(module, type->module_name, NULL, NULL, NULL); |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 265 | ly_print(out, "%*stype %s:%s", LEVEL, INDENT, str, type->der->name); |
Michal Vasko | 0fb82c6 | 2015-10-20 13:41:53 +0200 | [diff] [blame] | 266 | lydict_remove(module->ctx, str); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 267 | } else { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 268 | ly_print(out, "%*stype %s", LEVEL, INDENT, type->der->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 269 | } |
| 270 | level++; |
| 271 | switch (type->base) { |
| 272 | case LY_TYPE_BINARY: |
| 273 | if (type->info.binary.length != NULL) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 274 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 275 | ly_print(out, "%*slength \"%s\" {\n", LEVEL, INDENT, type->info.binary.length->expr); |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 276 | flag2 = 0; |
| 277 | yang_print_restr(out, level + 1, type->info.binary.length, &flag2); |
| 278 | yang_print_close(out, level, flag2); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 279 | } |
| 280 | break; |
| 281 | case LY_TYPE_BITS: |
| 282 | for (i = 0; i < type->info.bits.count; ++i) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 283 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 284 | ly_print(out, "%*sbit %s {\n", LEVEL, INDENT, type->info.bits.bit[i].name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 285 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 286 | yang_print_snode_common(out, level, (struct lys_node *)&type->info.bits.bit[i], NULL); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 287 | ly_print(out, "%*sposition %u;\n", LEVEL, INDENT, type->info.bits.bit[i].pos); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 288 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 289 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 290 | } |
| 291 | break; |
| 292 | case LY_TYPE_DEC64: |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 293 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 294 | ly_print(out, "%*sfraction-digits %d;\n", LEVEL, INDENT, type->info.dec64.dig); |
Michal Vasko | ea505ee | 2015-07-07 14:01:00 +0200 | [diff] [blame] | 295 | if (type->info.dec64.range != NULL) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 296 | ly_print(out, "%*srange \"%s\"", LEVEL, INDENT, type->info.dec64.range->expr); |
| 297 | flag2 = 0; |
| 298 | yang_print_restr(out, level + 1, type->info.dec64.range, &flag2); |
| 299 | yang_print_close(out, level, flag2); |
Michal Vasko | ea505ee | 2015-07-07 14:01:00 +0200 | [diff] [blame] | 300 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 301 | break; |
| 302 | case LY_TYPE_ENUM: |
| 303 | for (i = 0; i < type->info.enums.count; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 304 | yang_print_open(out, &flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 305 | ly_print(out, "%*senum \"%s\" {\n", LEVEL, INDENT, type->info.enums.enm[i].name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 306 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 307 | yang_print_snode_common(out, level, (struct lys_node *)&type->info.enums.enm[i], NULL); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 308 | ly_print(out, "%*svalue %d;\n", LEVEL, INDENT, type->info.enums.enm[i].value); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 309 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 310 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 311 | } |
| 312 | break; |
| 313 | case LY_TYPE_IDENT: |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 314 | yang_print_open(out, &flag); |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 315 | mod = type->info.ident.ref->module->type ? |
| 316 | ((struct lys_submodule *)type->info.ident.ref->module)->belongsto : |
| 317 | type->info.ident.ref->module; |
| 318 | if (module == mod) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 319 | ly_print(out, "%*sbase %s;\n", LEVEL, INDENT, type->info.ident.ref->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 320 | } else { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 321 | ly_print(out, "%*sbase %s:%s;\n", LEVEL, INDENT, mod->prefix, type->info.ident.ref->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 322 | } |
| 323 | break; |
| 324 | case LY_TYPE_INST: |
Radek Krejci | af35142 | 2015-06-19 14:49:38 +0200 | [diff] [blame] | 325 | if (type->info.inst.req == 1) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 326 | yang_print_open(out, &flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 327 | ly_print(out, "%*srequire-instance true;\n", LEVEL, INDENT); |
Radek Krejci | af35142 | 2015-06-19 14:49:38 +0200 | [diff] [blame] | 328 | } else if (type->info.inst.req == -1) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 329 | yang_print_open(out, &flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 330 | ly_print(out, "%*srequire-instance false;\n", LEVEL, INDENT); |
Radek Krejci | af35142 | 2015-06-19 14:49:38 +0200 | [diff] [blame] | 331 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 332 | break; |
| 333 | case LY_TYPE_INT8: |
| 334 | case LY_TYPE_INT16: |
| 335 | case LY_TYPE_INT32: |
| 336 | case LY_TYPE_INT64: |
| 337 | case LY_TYPE_UINT8: |
| 338 | case LY_TYPE_UINT16: |
| 339 | case LY_TYPE_UINT32: |
| 340 | case LY_TYPE_UINT64: |
Radek Krejci | f286013 | 2015-06-20 12:37:20 +0200 | [diff] [blame] | 341 | if (type->info.num.range != NULL) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 342 | yang_print_open(out, &flag); |
| 343 | ly_print(out, "%*srange \"%s\"", LEVEL, INDENT, type->info.num.range->expr); |
| 344 | flag2 = 0; |
| 345 | yang_print_restr(out, level + 1, type->info.num.range, &flag2); |
| 346 | yang_print_close(out, level, flag2); |
Radek Krejci | f286013 | 2015-06-20 12:37:20 +0200 | [diff] [blame] | 347 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 348 | break; |
| 349 | case LY_TYPE_LEAFREF: |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 350 | yang_print_open(out, &flag); |
Michal Vasko | fba1526 | 2015-10-21 12:10:28 +0200 | [diff] [blame] | 351 | str = transform_json2xml(module, type->info.lref.path, NULL, NULL, NULL); |
Michal Vasko | 514c4f3 | 2015-10-20 13:43:25 +0200 | [diff] [blame] | 352 | ly_print(out, "%*spath \"%s\";\n", LEVEL, INDENT, str); |
| 353 | lydict_remove(module->ctx, str); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 354 | break; |
| 355 | case LY_TYPE_STRING: |
Radek Krejci | 5fbc916 | 2015-06-19 14:11:11 +0200 | [diff] [blame] | 356 | if (type->info.str.length) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 357 | yang_print_open(out, &flag); |
| 358 | ly_print(out, "%*slength \"%s\"", LEVEL, INDENT, type->info.str.length->expr); |
| 359 | flag2 = 0; |
| 360 | yang_print_restr(out, level + 1, type->info.str.length, &flag2); |
| 361 | yang_print_close(out, level, flag2); |
Radek Krejci | 061bd52 | 2015-06-19 13:45:16 +0200 | [diff] [blame] | 362 | } |
Radek Krejci | 5fbc916 | 2015-06-19 14:11:11 +0200 | [diff] [blame] | 363 | for (i = 0; i < type->info.str.pat_count; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 364 | yang_print_open(out, &flag); |
| 365 | ly_print(out, "%*spattern \"%s\"", LEVEL, INDENT, type->info.str.patterns[i].expr); |
| 366 | flag2 = 0; |
| 367 | yang_print_restr(out, level + 1, &type->info.str.patterns[i], &flag2); |
| 368 | yang_print_close(out, level, flag2); |
Radek Krejci | 5fbc916 | 2015-06-19 14:11:11 +0200 | [diff] [blame] | 369 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 370 | break; |
| 371 | case LY_TYPE_UNION: |
| 372 | for (i = 0; i < type->info.uni.count; ++i) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 373 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 374 | yang_print_type(out, level, module, &type->info.uni.types[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 375 | } |
| 376 | break; |
| 377 | default: |
| 378 | /* other types do not have substatements */ |
| 379 | break; |
| 380 | } |
| 381 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 382 | yang_print_close(out, level, flag); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 383 | } |
| 384 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 385 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 386 | yang_print_must(struct lyout *out, int level, const struct lys_module *module, const struct lys_restr *must) |
Michal Vasko | 7f976ee | 2015-06-09 13:55:41 +0200 | [diff] [blame] | 387 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 388 | int flag = 0; |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 389 | const char *xml_expr; |
| 390 | |
Michal Vasko | fba1526 | 2015-10-21 12:10:28 +0200 | [diff] [blame] | 391 | xml_expr = transform_json2xml(module, must->expr, NULL, NULL, NULL); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 392 | if (!xml_expr) { |
| 393 | ly_print(out, "(!error!)"); |
| 394 | return; |
| 395 | } |
| 396 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 397 | ly_print(out, "%*smust \"%s\"", LEVEL, INDENT, xml_expr); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 398 | lydict_remove(module->ctx, xml_expr); |
| 399 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 400 | yang_print_restr(out, level + 1, must, &flag); |
| 401 | yang_print_close(out, level, flag); |
Michal Vasko | 7f976ee | 2015-06-09 13:55:41 +0200 | [diff] [blame] | 402 | } |
| 403 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 404 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 405 | yang_print_unique(struct lyout *out, int level, const struct lys_unique *uniq) |
Michal Vasko | 1ef0797 | 2015-07-07 14:01:35 +0200 | [diff] [blame] | 406 | { |
| 407 | int i; |
| 408 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 409 | ly_print(out, "%*sunique \"", LEVEL, INDENT); |
Radek Krejci | 581ce77 | 2015-11-10 17:22:40 +0100 | [diff] [blame] | 410 | for (i = 0; i < uniq->expr_size; i++) { |
| 411 | ly_print(out, "%s%s", uniq->expr[i], i + 1 < uniq->expr_size ? " " : ""); |
Michal Vasko | 1ef0797 | 2015-07-07 14:01:35 +0200 | [diff] [blame] | 412 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 413 | ly_print(out, "\";\n"); |
Michal Vasko | 1ef0797 | 2015-07-07 14:01:35 +0200 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 417 | yang_print_refine(struct lyout *out, int level, const struct lys_module *module, const struct lys_refine *refine) |
Michal Vasko | 00b7cfe | 2015-06-09 13:56:38 +0200 | [diff] [blame] | 418 | { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 419 | int i; |
Michal Vasko | a8b2595 | 2015-10-20 15:30:25 +0200 | [diff] [blame] | 420 | const char *str; |
Michal Vasko | 00b7cfe | 2015-06-09 13:56:38 +0200 | [diff] [blame] | 421 | |
Michal Vasko | fba1526 | 2015-10-21 12:10:28 +0200 | [diff] [blame] | 422 | str = transform_json2xml(module, refine->target_name, NULL, NULL, NULL); |
Michal Vasko | a8b2595 | 2015-10-20 15:30:25 +0200 | [diff] [blame] | 423 | ly_print(out, "%*srefine \"%s\" {\n", LEVEL, INDENT, str); |
| 424 | lydict_remove(module->ctx, str); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 425 | level++; |
Michal Vasko | 00b7cfe | 2015-06-09 13:56:38 +0200 | [diff] [blame] | 426 | |
Radek Krejci | 1574a8d | 2015-08-03 14:16:52 +0200 | [diff] [blame] | 427 | if (refine->flags & LYS_CONFIG_W) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 428 | ly_print(out, "%*sconfig true;\n", LEVEL, INDENT); |
Radek Krejci | 1574a8d | 2015-08-03 14:16:52 +0200 | [diff] [blame] | 429 | } else if (refine->flags & LYS_CONFIG_R) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 430 | ly_print(out, "%*sconfig false;\n", LEVEL, INDENT); |
Radek Krejci | 6a11385 | 2015-07-03 16:04:20 +0200 | [diff] [blame] | 431 | } |
| 432 | |
Radek Krejci | 1574a8d | 2015-08-03 14:16:52 +0200 | [diff] [blame] | 433 | if (refine->flags & LYS_MAND_TRUE) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 434 | ly_print(out, "%*smandatory true;\n", LEVEL, INDENT); |
Radek Krejci | 1574a8d | 2015-08-03 14:16:52 +0200 | [diff] [blame] | 435 | } else if (refine->flags & LYS_MAND_FALSE) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 436 | ly_print(out, "%*smandatory false;\n", LEVEL, INDENT); |
Radek Krejci | 6a11385 | 2015-07-03 16:04:20 +0200 | [diff] [blame] | 437 | } |
| 438 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 439 | yang_print_snode_common(out, level, (struct lys_node *)refine, NULL); |
Michal Vasko | 00b7cfe | 2015-06-09 13:56:38 +0200 | [diff] [blame] | 440 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 441 | for (i = 0; i < refine->must_size; ++i) { |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 442 | yang_print_must(out, level, module, &refine->must[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 443 | } |
Michal Vasko | 00b7cfe | 2015-06-09 13:56:38 +0200 | [diff] [blame] | 444 | |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 445 | if (refine->target_type & (LYS_LEAF | LYS_CHOICE)) { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 446 | if (refine->mod.dflt != NULL) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 447 | ly_print(out, "%*sdefault \"%s\";\n", LEVEL, INDENT, refine->mod.dflt); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 448 | } |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 449 | } else if (refine->target_type == LYS_CONTAINER) { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 450 | if (refine->mod.presence != NULL) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 451 | yang_print_text(out, level, "presence", refine->mod.presence, 1); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 452 | } |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 453 | } else if (refine->target_type & (LYS_LIST | LYS_LEAFLIST)) { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 454 | if (refine->mod.list.min > 0) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 455 | ly_print(out, "%*smin-elements %u;\n", LEVEL, INDENT, refine->mod.list.min); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 456 | } |
| 457 | if (refine->mod.list.max > 0) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 458 | ly_print(out, "%*smax-elements %u;\n", LEVEL, INDENT, refine->mod.list.max); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 459 | } |
| 460 | } |
Michal Vasko | 00b7cfe | 2015-06-09 13:56:38 +0200 | [diff] [blame] | 461 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 462 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 463 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Michal Vasko | 00b7cfe | 2015-06-09 13:56:38 +0200 | [diff] [blame] | 464 | } |
| 465 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 466 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 467 | yang_print_deviation(struct lyout *out, int level, const struct lys_module *module, |
| 468 | const struct lys_deviation *deviation) |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 469 | { |
| 470 | int i, j; |
Michal Vasko | a8b2595 | 2015-10-20 15:30:25 +0200 | [diff] [blame] | 471 | const char *str; |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 472 | |
Michal Vasko | fba1526 | 2015-10-21 12:10:28 +0200 | [diff] [blame] | 473 | str = transform_json2xml(module, deviation->target_name, NULL, NULL, NULL); |
Michal Vasko | a8b2595 | 2015-10-20 15:30:25 +0200 | [diff] [blame] | 474 | ly_print(out, "%*sdeviation \"%s\" {\n", LEVEL, INDENT, str); |
| 475 | lydict_remove(module->ctx, str); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 476 | level++; |
| 477 | |
| 478 | if (deviation->dsc) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 479 | yang_print_text(out, level, "description", deviation->dsc, 0); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 480 | } |
| 481 | if (deviation->ref) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 482 | yang_print_text(out, level, "reference", deviation->ref, 0); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | for (i = 0; i < deviation->deviate_size; ++i) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 486 | ly_print(out, "%*sdeviate ", LEVEL, INDENT); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 487 | if (deviation->deviate[i].mod == LY_DEVIATE_NO) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 488 | ly_print(out, "not-supported {\n"); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 489 | } else if (deviation->deviate[i].mod == LY_DEVIATE_ADD) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 490 | ly_print(out, "add {\n"); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 491 | } else if (deviation->deviate[i].mod == LY_DEVIATE_RPL) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 492 | ly_print(out, "replace {\n"); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 493 | } else if (deviation->deviate[i].mod == LY_DEVIATE_DEL) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 494 | ly_print(out, "delete {\n"); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 495 | } |
| 496 | level++; |
| 497 | |
Radek Krejci | 1574a8d | 2015-08-03 14:16:52 +0200 | [diff] [blame] | 498 | if (deviation->deviate[i].flags & LYS_CONFIG_W) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 499 | ly_print(out, "%*sconfig true;\n", LEVEL, INDENT); |
Radek Krejci | 1574a8d | 2015-08-03 14:16:52 +0200 | [diff] [blame] | 500 | } else if (deviation->deviate[i].flags & LYS_CONFIG_R) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 501 | ly_print(out, "%*sconfig false;\n", LEVEL, INDENT); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 502 | } |
| 503 | |
Radek Krejci | 1574a8d | 2015-08-03 14:16:52 +0200 | [diff] [blame] | 504 | if (deviation->deviate[i].flags & LYS_MAND_TRUE) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 505 | ly_print(out, "%*smandatory true;\n", LEVEL, INDENT); |
Radek Krejci | 1574a8d | 2015-08-03 14:16:52 +0200 | [diff] [blame] | 506 | } else if (deviation->deviate[i].flags & LYS_MAND_FALSE) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 507 | ly_print(out, "%*smandatory false;\n", LEVEL, INDENT); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | if (deviation->deviate[i].dflt) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 511 | ly_print(out, "%*sdefault %s;\n", LEVEL, INDENT, deviation->deviate[i].dflt); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | if (deviation->deviate[i].min) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 515 | ly_print(out, "%*smin-elements %u;\n", LEVEL, INDENT, deviation->deviate[i].min); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 516 | } |
| 517 | if (deviation->deviate[i].max) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 518 | ly_print(out, "%*smax-elements %u;\n", LEVEL, INDENT, deviation->deviate[i].max); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | for (j = 0; j < deviation->deviate[i].must_size; ++j) { |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 522 | yang_print_must(out, level, module, &deviation->deviate[i].must[j]); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | for (j = 0; j < deviation->deviate[i].unique_size; ++j) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 526 | yang_print_unique(out, level, &deviation->deviate[i].unique[j]); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | if (deviation->deviate[i].type) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 530 | yang_print_type(out, level, module, deviation->deviate[i].type); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | if (deviation->deviate[i].units) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 534 | ly_print(out, "%*sunits %s;\n", LEVEL, INDENT, deviation->deviate[i].units); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 538 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 542 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Michal Vasko | e0af1e2 | 2015-07-07 14:02:02 +0200 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 546 | yang_print_augment(struct lyout *out, int level, const struct lys_module *module, |
| 547 | const struct lys_node_augment *augment) |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 548 | { |
| 549 | int i; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 550 | struct lys_node *sub; |
Michal Vasko | 488c19e | 2015-10-20 15:21:00 +0200 | [diff] [blame] | 551 | const char *str; |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 552 | |
Michal Vasko | fba1526 | 2015-10-21 12:10:28 +0200 | [diff] [blame] | 553 | str = transform_json2xml(module, augment->target_name, NULL, NULL, NULL); |
Michal Vasko | 488c19e | 2015-10-20 15:21:00 +0200 | [diff] [blame] | 554 | ly_print(out, "%*saugment \"%s\" {\n", LEVEL, INDENT, str); |
| 555 | lydict_remove(module->ctx, str); |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 556 | level++; |
| 557 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 558 | yang_print_nacmext(out, level, (struct lys_node *)augment, module, NULL); |
| 559 | yang_print_snode_common(out, level, (struct lys_node *)augment, NULL); |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 560 | |
| 561 | for (i = 0; i < augment->features_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 562 | yang_print_iffeature(out, level, module, augment->features[i]); |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | if (augment->when) { |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 566 | yang_print_when(out, level, module, augment->when); |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | LY_TREE_FOR(augment->child, sub) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 570 | yang_print_snode(out, level, sub, |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 571 | LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | |
| 572 | LYS_USES | LYS_ANYXML | LYS_CASE); |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 576 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 580 | yang_print_typedef(struct lyout *out, int level, const struct lys_module *module, const struct lys_tpdf *tpdf) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 581 | { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 582 | ly_print(out, "%*stypedef %s {\n", LEVEL, INDENT, tpdf->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 583 | level++; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 584 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 585 | yang_print_snode_common(out, level, (struct lys_node *)tpdf, NULL); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 586 | yang_print_type(out, level, module, &tpdf->type); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 587 | if (tpdf->units != NULL) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 588 | ly_print(out, "%*sunits \"%s\";\n", LEVEL, INDENT, tpdf->units); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 589 | } |
| 590 | if (tpdf->dflt != NULL) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 591 | ly_print(out, "%*sdefault \"%s\";\n", LEVEL, INDENT, tpdf->dflt); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 592 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 593 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 594 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 595 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 596 | } |
| 597 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 598 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 599 | yang_print_identity(struct lyout *out, int level, const struct lys_ident *ident) |
Radek Krejci | 6793db0 | 2015-05-22 17:49:54 +0200 | [diff] [blame] | 600 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 601 | int flag = 0; |
| 602 | |
| 603 | ly_print(out, "%*sidentity %s", LEVEL, INDENT, ident->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 604 | level++; |
Radek Krejci | 6793db0 | 2015-05-22 17:49:54 +0200 | [diff] [blame] | 605 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 606 | yang_print_snode_common(out, level, (struct lys_node *)ident, &flag); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 607 | if (ident->base) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 608 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 609 | ly_print(out, "%*sbase ", LEVEL, INDENT); |
Michal Vasko | c39c4b1 | 2015-07-07 14:55:33 +0200 | [diff] [blame] | 610 | if ((ident->module != ident->base->module) && !ident->base->module->type) { |
Michal Vasko | 2d851a9 | 2015-10-20 16:16:36 +0200 | [diff] [blame] | 611 | ly_print(out, "%s:", ident->base->module->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 612 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 613 | ly_print(out, "%s;\n", ident->base->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 614 | } |
Radek Krejci | 6793db0 | 2015-05-22 17:49:54 +0200 | [diff] [blame] | 615 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 616 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 617 | yang_print_close(out, level, flag); |
Radek Krejci | 6793db0 | 2015-05-22 17:49:54 +0200 | [diff] [blame] | 618 | } |
| 619 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 620 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 621 | yang_print_container(struct lyout *out, int level, const struct lys_node *node) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 622 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 623 | int i, flag = 0; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 624 | struct lys_node *sub; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 625 | struct lys_node_container *cont = (struct lys_node_container *)node; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 626 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 627 | ly_print(out, "%*scontainer %s", LEVEL, INDENT, node->name); |
Michal Vasko | 7f976ee | 2015-06-09 13:55:41 +0200 | [diff] [blame] | 628 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 629 | level++; |
Radek Krejci | 6a11385 | 2015-07-03 16:04:20 +0200 | [diff] [blame] | 630 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 631 | yang_print_nacmext(out, level, node, node->module, &flag); |
Radek Krejci | 6a11385 | 2015-07-03 16:04:20 +0200 | [diff] [blame] | 632 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 633 | if (cont->when) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 634 | yang_print_open(out, &flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 635 | yang_print_when(out, level, node->module, cont->when); |
| 636 | } |
| 637 | |
| 638 | for (i = 0; i < cont->features_size; i++) { |
| 639 | yang_print_open(out, &flag); |
| 640 | yang_print_iffeature(out, level, node->module, cont->features[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 641 | } |
Michal Vasko | 7f976ee | 2015-06-09 13:55:41 +0200 | [diff] [blame] | 642 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 643 | for (i = 0; i < cont->must_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 644 | yang_print_open(out, &flag); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 645 | yang_print_must(out, level, node->module, &cont->must[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 646 | } |
Michal Vasko | 7f976ee | 2015-06-09 13:55:41 +0200 | [diff] [blame] | 647 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 648 | if (cont->presence != NULL) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 649 | yang_print_open(out, &flag); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 650 | yang_print_text(out, level, "presence", cont->presence, 1); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 651 | } |
| 652 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 653 | yang_print_snode_common2(out, level, node, &flag); |
| 654 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 655 | for (i = 0; i < cont->tpdf_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 656 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 657 | yang_print_typedef(out, level, node->module, &cont->tpdf[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 658 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 659 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 660 | LY_TREE_FOR(node->child, sub) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 661 | /* augment and data from submodules */ |
| 662 | if (sub->module != node->module) { |
Michal Vasko | 15b4870 | 2015-07-07 15:49:34 +0200 | [diff] [blame] | 663 | continue; |
| 664 | } |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 665 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 666 | yang_print_snode(out, level, sub, |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 667 | LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | |
| 668 | LYS_USES | LYS_GROUPING | LYS_ANYXML); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 669 | } |
Michal Vasko | c1329bc | 2015-06-09 13:58:18 +0200 | [diff] [blame] | 670 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 671 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 672 | yang_print_close(out, level, flag); |
Michal Vasko | c1329bc | 2015-06-09 13:58:18 +0200 | [diff] [blame] | 673 | } |
| 674 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 675 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 676 | yang_print_case(struct lyout *out, int level, const struct lys_node *node) |
Michal Vasko | c1329bc | 2015-06-09 13:58:18 +0200 | [diff] [blame] | 677 | { |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 678 | int i; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 679 | struct lys_node *sub; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 680 | struct lys_node_case *cas = (struct lys_node_case *)node; |
Michal Vasko | c1329bc | 2015-06-09 13:58:18 +0200 | [diff] [blame] | 681 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 682 | ly_print(out, "%*scase %s {\n", LEVEL, INDENT, cas->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 683 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 684 | yang_print_nacmext(out, level, node, node->module, NULL); |
| 685 | yang_print_snode_common2(out, level, node, NULL); |
Michal Vasko | c1329bc | 2015-06-09 13:58:18 +0200 | [diff] [blame] | 686 | |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 687 | for (i = 0; i < cas->features_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 688 | yang_print_iffeature(out, level, node->module, cas->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 689 | } |
| 690 | |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 691 | if (cas->when) { |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 692 | yang_print_when(out, level, node->module, cas->when); |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 693 | } |
| 694 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 695 | LY_TREE_FOR(node->child, sub) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 696 | /* augment and data from submodules */ |
| 697 | if (sub->module != node->module) { |
Michal Vasko | 15b4870 | 2015-07-07 15:49:34 +0200 | [diff] [blame] | 698 | continue; |
| 699 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 700 | yang_print_snode(out, level, sub, |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 701 | LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | |
| 702 | LYS_USES | LYS_ANYXML); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 703 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 704 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 705 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 706 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 707 | } |
| 708 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 709 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 710 | yang_print_choice(struct lyout *out, int level, const struct lys_node *node) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 711 | { |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 712 | int i; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 713 | struct lys_node *sub; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 714 | struct lys_node_choice *choice = (struct lys_node_choice *)node; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 715 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 716 | ly_print(out, "%*schoice %s {\n", LEVEL, INDENT, node->name); |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 717 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 718 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 719 | yang_print_nacmext(out, level, node, node->module, NULL); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 720 | if (choice->dflt != NULL) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 721 | ly_print(out, "%*sdefault \"%s\";\n", LEVEL, INDENT, choice->dflt->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 722 | } |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 723 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 724 | yang_print_snode_common2(out, level, node, NULL); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 725 | |
| 726 | for (i = 0; i < choice->features_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 727 | yang_print_iffeature(out, level, node->module, choice->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 728 | } |
| 729 | |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 730 | if (choice->when) { |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 731 | yang_print_when(out, level, node->module, choice->when); |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 732 | } |
| 733 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 734 | LY_TREE_FOR(node->child, sub) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 735 | /* augment and data from submodules */ |
| 736 | if (sub->module != node->module) { |
Michal Vasko | 15b4870 | 2015-07-07 15:49:34 +0200 | [diff] [blame] | 737 | continue; |
| 738 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 739 | yang_print_snode(out, level, sub, |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 740 | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | LYS_ANYXML | LYS_CASE); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 741 | } |
| 742 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 743 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 744 | } |
| 745 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 746 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 747 | yang_print_leaf(struct lyout *out, int level, const struct lys_node *node) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 748 | { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 749 | int i; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 750 | struct lys_node_leaf *leaf = (struct lys_node_leaf *)node; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 751 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 752 | ly_print(out, "%*sleaf %s {\n", LEVEL, INDENT, node->name); |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 753 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 754 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 755 | yang_print_nacmext(out, level, node, node->module, NULL); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 756 | if (leaf->when) { |
| 757 | yang_print_when(out, level, node->module, leaf->when); |
| 758 | } |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 759 | for (i = 0; i < leaf->features_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 760 | yang_print_iffeature(out, level, node->module, leaf->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 761 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 762 | for (i = 0; i < leaf->must_size; i++) { |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 763 | yang_print_must(out, level, node->module, &leaf->must[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 764 | } |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 765 | yang_print_snode_common2(out, level, node, NULL); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 766 | yang_print_type(out, level, node->module, &leaf->type); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 767 | if (leaf->units != NULL) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 768 | ly_print(out, "%*sunits \"%s\";\n", LEVEL, INDENT, leaf->units); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 769 | } |
| 770 | if (leaf->dflt != NULL) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 771 | switch (leaf->type.base) { |
| 772 | case LY_TYPE_STRING: |
| 773 | case LY_TYPE_LEAFREF: |
| 774 | case LY_TYPE_IDENT: |
| 775 | case LY_TYPE_UNION: |
| 776 | ly_print(out, "%*sdefault \"%s\";\n", LEVEL, INDENT, leaf->dflt); |
| 777 | break; |
| 778 | default: |
| 779 | ly_print(out, "%*sdefault %s;\n", LEVEL, INDENT, leaf->dflt); |
| 780 | break; |
| 781 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 782 | } |
| 783 | level--; |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 784 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 785 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 786 | } |
| 787 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 788 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 789 | yang_print_anyxml(struct lyout *out, int level, const struct lys_node *node) |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 790 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 791 | int i, flag = 0; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 792 | struct lys_node_anyxml *anyxml = (struct lys_node_anyxml *)node; |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 793 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 794 | ly_print(out, "%*sanyxml %s", LEVEL, INDENT, anyxml->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 795 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 796 | yang_print_nacmext(out, level, node, node->module, &flag); |
| 797 | yang_print_snode_common2(out, level, node, &flag); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 798 | for (i = 0; i < anyxml->features_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 799 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 800 | yang_print_iffeature(out, level, node->module, anyxml->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 801 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 802 | for (i = 0; i < anyxml->must_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 803 | yang_print_open(out, &flag); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 804 | yang_print_must(out, level, node->module, &anyxml->must[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 805 | } |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 806 | if (anyxml->when) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 807 | yang_print_open(out, &flag); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 808 | yang_print_when(out, level, node->module, anyxml->when); |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 809 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 810 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 811 | yang_print_close(out, level, flag); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 812 | } |
| 813 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 814 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 815 | yang_print_leaflist(struct lyout *out, int level, const struct lys_node *node) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 816 | { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 817 | int i; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 818 | struct lys_node_leaflist *llist = (struct lys_node_leaflist *)node; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 819 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 820 | ly_print(out, "%*sleaf-list %s {\n", LEVEL, INDENT, node->name); |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 821 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 822 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 823 | yang_print_nacmext(out, level, node, node->module, NULL); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 824 | if (llist->when) { |
| 825 | yang_print_when(out, level, llist->module, llist->when); |
| 826 | } |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 827 | for (i = 0; i < llist->features_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 828 | yang_print_iffeature(out, level, node->module, llist->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 829 | } |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 830 | for (i = 0; i < llist->must_size; i++) { |
| 831 | yang_print_must(out, level, node->module, &llist->must[i]); |
| 832 | } |
| 833 | yang_print_snode_common2(out, level, node, NULL); |
| 834 | yang_print_type(out, level, node->module, &llist->type); |
| 835 | if (llist->units != NULL) { |
| 836 | ly_print(out, "%*sunits \"%s\";\n", LEVEL, INDENT, llist->units); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 837 | } |
| 838 | if (llist->min > 0) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 839 | ly_print(out, "%*smin-elements %u;\n", LEVEL, INDENT, llist->min); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 840 | } |
| 841 | if (llist->max > 0) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 842 | ly_print(out, "%*smax-elements %u;\n", LEVEL, INDENT, llist->max); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 843 | } |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 844 | if (llist->flags & LYS_USERORDERED) { |
| 845 | ly_print(out, "%*sordered-by user;\n", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 846 | } |
| 847 | level--; |
Michal Vasko | 1608366 | 2015-06-09 14:00:45 +0200 | [diff] [blame] | 848 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 849 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 850 | } |
| 851 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 852 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 853 | yang_print_list(struct lyout *out, int level, const struct lys_node *node) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 854 | { |
Michal Vasko | 1ef0797 | 2015-07-07 14:01:35 +0200 | [diff] [blame] | 855 | int i; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 856 | struct lys_node *sub; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 857 | struct lys_node_list *list = (struct lys_node_list *)node; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 858 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 859 | ly_print(out, "%*slist %s {\n", LEVEL, INDENT, node->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 860 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 861 | yang_print_nacmext(out, level, node, node->module, NULL); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 862 | if (list->when) { |
| 863 | yang_print_when(out, level, list->module, list->when); |
| 864 | } |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 865 | for (i = 0; i < list->features_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 866 | yang_print_iffeature(out, level, node->module, list->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 867 | } |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 868 | for (i = 0; i < list->must_size; i++) { |
| 869 | yang_print_must(out, level, list->module, &list->must[i]); |
| 870 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 871 | if (list->keys_size) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 872 | ly_print(out, "%*skey \"", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 873 | for (i = 0; i < list->keys_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 874 | ly_print(out, "%s%s", list->keys[i]->name, i + 1 < list->keys_size ? " " : ""); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 875 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 876 | ly_print(out, "\";\n"); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 877 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 878 | for (i = 0; i < list->unique_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 879 | yang_print_unique(out, level, &list->unique[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 880 | } |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 881 | yang_print_snode_common2(out, level, node, NULL); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 882 | if (list->min > 0) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 883 | ly_print(out, "%*smin-elements %u;\n", LEVEL, INDENT, list->min); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 884 | } |
| 885 | if (list->max > 0) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 886 | ly_print(out, "%*smax-elements %u;\n", LEVEL, INDENT, list->max); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 887 | } |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 888 | if (list->flags & LYS_USERORDERED) { |
| 889 | ly_print(out, "%*sordered-by user;\n", LEVEL, INDENT); |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 890 | } |
Michal Vasko | dff818b | 2015-06-09 14:01:12 +0200 | [diff] [blame] | 891 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 892 | for (i = 0; i < list->tpdf_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 893 | yang_print_typedef(out, level, list->module, &list->tpdf[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 894 | } |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 895 | LY_TREE_FOR(node->child, sub) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 896 | /* augment and data from submodules */ |
| 897 | if (sub->module != node->module) { |
Michal Vasko | 15b4870 | 2015-07-07 15:49:34 +0200 | [diff] [blame] | 898 | continue; |
| 899 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 900 | yang_print_snode(out, level, sub, |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 901 | LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | |
| 902 | LYS_USES | LYS_GROUPING | LYS_ANYXML); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 903 | } |
| 904 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 905 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 906 | } |
| 907 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 908 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 909 | yang_print_grouping(struct lyout *out, int level, const struct lys_node *node) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 910 | { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 911 | int i; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 912 | struct lys_node *child; |
| 913 | struct lys_node_grp *grp = (struct lys_node_grp *)node; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 914 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 915 | ly_print(out, "%*sgrouping %s {\n", LEVEL, INDENT, node->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 916 | level++; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 917 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 918 | yang_print_snode_common(out, level, node, NULL); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 919 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 920 | for (i = 0; i < grp->tpdf_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 921 | yang_print_typedef(out, level, node->module, &grp->tpdf[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 922 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 923 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 924 | LY_TREE_FOR(node->child, child) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 925 | yang_print_snode(out, level, child, |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 926 | LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | |
| 927 | LYS_USES | LYS_GROUPING | LYS_ANYXML); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 928 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 929 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 930 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 931 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 932 | } |
| 933 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 934 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 935 | yang_print_uses(struct lyout *out, int level, const struct lys_node *node) |
Radek Krejci | c7c9a6c | 2015-05-25 16:35:06 +0200 | [diff] [blame] | 936 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 937 | int i, flag = 0; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 938 | struct lys_node_uses *uses = (struct lys_node_uses *)node; |
Radek Krejci | c7c9a6c | 2015-05-25 16:35:06 +0200 | [diff] [blame] | 939 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 940 | ly_print(out, "%*suses ", LEVEL, INDENT); |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 941 | if (node->child && (node->module != node->child->module) && !node->child->module->type) { |
Michal Vasko | 2d851a9 | 2015-10-20 16:16:36 +0200 | [diff] [blame] | 942 | ly_print(out, "%s:", node->child->module->name); |
Michal Vasko | c39c4b1 | 2015-07-07 14:55:33 +0200 | [diff] [blame] | 943 | } |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 944 | ly_print(out, "%s", uses->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 945 | level++; |
Radek Krejci | c7c9a6c | 2015-05-25 16:35:06 +0200 | [diff] [blame] | 946 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 947 | yang_print_nacmext(out, level, node, node->module, &flag); |
| 948 | yang_print_snode_common(out, level, node, &flag); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 949 | for (i = 0; i < uses->features_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 950 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 951 | yang_print_iffeature(out, level, node->module, uses->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 952 | } |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 953 | if (uses->when) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 954 | yang_print_open(out, &flag); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 955 | yang_print_when(out, level, node->module, uses->when); |
Michal Vasko | 1f0428a | 2015-07-07 14:55:04 +0200 | [diff] [blame] | 956 | } |
Radek Krejci | c7c9a6c | 2015-05-25 16:35:06 +0200 | [diff] [blame] | 957 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 958 | for (i = 0; i < uses->refine_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 959 | yang_print_open(out, &flag); |
Michal Vasko | f989338 | 2015-10-09 14:03:04 +0200 | [diff] [blame] | 960 | yang_print_refine(out, level, node->module, &uses->refine[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 961 | } |
Michal Vasko | 00b7cfe | 2015-06-09 13:56:38 +0200 | [diff] [blame] | 962 | |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 963 | for (i = 0; i < uses->augment_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 964 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 965 | yang_print_augment(out, level, node->module, &uses->augment[i]); |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 966 | } |
| 967 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 968 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 969 | yang_print_close(out, level, flag); |
Radek Krejci | c7c9a6c | 2015-05-25 16:35:06 +0200 | [diff] [blame] | 970 | } |
| 971 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 972 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 973 | yang_print_input_output(struct lyout *out, int level, const struct lys_node *node) |
Michal Vasko | 5bbae10 | 2015-06-16 12:16:44 +0200 | [diff] [blame] | 974 | { |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 975 | int i; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 976 | struct lys_node *sub; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 977 | struct lys_node_rpc_inout *inout = (struct lys_node_rpc_inout *)node; |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 978 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 979 | ly_print(out, "%*s%s {\n", LEVEL, INDENT, (inout->nodetype == LYS_INPUT ? "input" : "output")); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 980 | |
| 981 | level++; |
| 982 | for (i = 0; i < inout->tpdf_size; i++) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 983 | yang_print_typedef(out, level, node->module, &inout->tpdf[i]); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 984 | } |
| 985 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 986 | LY_TREE_FOR(node->child, sub) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 987 | /* augment and data from submodules */ |
| 988 | if (sub->module != node->module) { |
Michal Vasko | 15b4870 | 2015-07-07 15:49:34 +0200 | [diff] [blame] | 989 | continue; |
| 990 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 991 | yang_print_snode(out, level, sub, |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 992 | LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | |
| 993 | LYS_USES | LYS_GROUPING | LYS_ANYXML); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 997 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 1001 | yang_print_rpc(struct lyout *out, int level, const struct lys_node *node) |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1002 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1003 | int i, flag = 0; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1004 | struct lys_node *sub; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 1005 | struct lys_node_rpc *rpc = (struct lys_node_rpc *)node; |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1006 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1007 | ly_print(out, "%*srpc %s", LEVEL, INDENT, node->name); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1008 | |
| 1009 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1010 | yang_print_snode_common(out, level, node, &flag); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1011 | |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 1012 | for (i = 0; i < rpc->features_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1013 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1014 | yang_print_iffeature(out, level, node->module, rpc->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 1015 | } |
| 1016 | |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1017 | for (i = 0; i < rpc->tpdf_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1018 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1019 | yang_print_typedef(out, level, node->module, &rpc->tpdf[i]); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1020 | } |
| 1021 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 1022 | LY_TREE_FOR(node->child, sub) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 1023 | /* augment and data from submodules */ |
| 1024 | if (sub->module != node->module) { |
| 1025 | continue; |
| 1026 | } |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1027 | yang_print_open(out, &flag); |
| 1028 | yang_print_snode(out, level, sub, LYS_GROUPING | LYS_INPUT | LYS_OUTPUT); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1032 | yang_print_close(out, level, flag); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1033 | } |
| 1034 | |
| 1035 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 1036 | yang_print_notif(struct lyout *out, int level, const struct lys_node *node) |
Michal Vasko | 7690bc1 | 2015-06-16 12:26:05 +0200 | [diff] [blame] | 1037 | { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1038 | int i, flag = 0; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1039 | struct lys_node *sub; |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 1040 | struct lys_node_notif *notif = (struct lys_node_notif *)node; |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1041 | |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1042 | ly_print(out, "%*snotification %s", LEVEL, INDENT, node->name); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1043 | |
| 1044 | level++; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1045 | yang_print_snode_common(out, level, node, &flag); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1046 | |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 1047 | for (i = 0; i < notif->features_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1048 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1049 | yang_print_iffeature(out, level, node->module, notif->features[i]); |
Michal Vasko | 4773b76 | 2015-07-07 12:15:10 +0200 | [diff] [blame] | 1050 | } |
| 1051 | |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1052 | for (i = 0; i < notif->tpdf_size; i++) { |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1053 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1054 | yang_print_typedef(out, level, node->module, ¬if->tpdf[i]); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1055 | } |
| 1056 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 1057 | LY_TREE_FOR(node->child, sub) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 1058 | /* augment and data from submodules */ |
| 1059 | if (sub->module != node->module) { |
Michal Vasko | 15b4870 | 2015-07-07 15:49:34 +0200 | [diff] [blame] | 1060 | continue; |
| 1061 | } |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1062 | yang_print_open(out, &flag); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1063 | yang_print_snode(out, level, sub, |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1064 | LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | |
| 1065 | LYS_USES | LYS_GROUPING | LYS_ANYXML); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1066 | } |
| 1067 | |
| 1068 | level--; |
Radek Krejci | 32cce7c | 2015-12-09 16:44:13 +0100 | [diff] [blame] | 1069 | yang_print_close(out, level, flag); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1070 | } |
| 1071 | |
| 1072 | static void |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 1073 | yang_print_snode(struct lyout *out, int level, const struct lys_node *node, int mask) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1074 | { |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 1075 | switch (node->nodetype & mask) { |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1076 | case LYS_CONTAINER: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1077 | yang_print_container(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1078 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1079 | case LYS_CHOICE: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1080 | yang_print_choice(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1081 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1082 | case LYS_LEAF: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1083 | yang_print_leaf(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1084 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1085 | case LYS_LEAFLIST: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1086 | yang_print_leaflist(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1087 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1088 | case LYS_LIST: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1089 | yang_print_list(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1090 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1091 | case LYS_USES: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1092 | yang_print_uses(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1093 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1094 | case LYS_GROUPING: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1095 | yang_print_grouping(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1096 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1097 | case LYS_ANYXML: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1098 | yang_print_anyxml(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1099 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1100 | case LYS_CASE: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1101 | yang_print_case(out, level, node); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1102 | break; |
Radek Krejci | 7651257 | 2015-08-04 09:47:08 +0200 | [diff] [blame] | 1103 | case LYS_INPUT: |
| 1104 | case LYS_OUTPUT: |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1105 | yang_print_input_output(out, level, node); |
Michal Vasko | f4d3d74 | 2015-06-16 11:51:09 +0200 | [diff] [blame] | 1106 | break; |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1107 | default: |
| 1108 | break; |
| 1109 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1110 | } |
| 1111 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1112 | int |
Michal Vasko | 1e62a09 | 2015-12-01 12:27:20 +0100 | [diff] [blame] | 1113 | yang_print_model(struct lyout *out, const struct lys_module *module) |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1114 | { |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1115 | unsigned int i; |
| 1116 | int level = 0; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1117 | #define LEVEL (level*2) |
| 1118 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 1119 | struct lys_node *node; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1120 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1121 | /* (sub)module-header-stmts */ |
Michal Vasko | 116172e | 2015-07-07 11:54:37 +0200 | [diff] [blame] | 1122 | if (module->type) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1123 | ly_print(out, "submodule %s {%s\n", module->name, (module->deviated ? " // DEVIATED" : "")); |
Michal Vasko | 116172e | 2015-07-07 11:54:37 +0200 | [diff] [blame] | 1124 | level++; |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1125 | if (module->version) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 1126 | ly_print(out, "%*syang-version %s;\n", LEVEL, INDENT, |
| 1127 | ((struct lys_submodule *)module)->belongsto->version == 2 ? "1.1" : "1"); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1128 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1129 | ly_print(out, "%*sbelongs-to %s {\n", LEVEL, INDENT, ((struct lys_submodule *)module)->belongsto->name); |
Michal Vasko | 116172e | 2015-07-07 11:54:37 +0200 | [diff] [blame] | 1130 | level++; |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1131 | ly_print(out, "%*sprefix %s;\n", LEVEL, INDENT, module->prefix); |
Michal Vasko | 116172e | 2015-07-07 11:54:37 +0200 | [diff] [blame] | 1132 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1133 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Michal Vasko | 116172e | 2015-07-07 11:54:37 +0200 | [diff] [blame] | 1134 | } else { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1135 | ly_print(out, "module %s {%s\n", module->name, (module->deviated ? " // DEVIATED" : "")); |
Michal Vasko | 116172e | 2015-07-07 11:54:37 +0200 | [diff] [blame] | 1136 | level++; |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1137 | if (module->version) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 1138 | ly_print(out, "%*syang-version %s;\n", LEVEL, INDENT, module->version == 2 ? "1.1" : "1"); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1139 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1140 | ly_print(out, "%*snamespace \"%s\";\n", LEVEL, INDENT, module->ns); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1141 | ly_print(out, "%*sprefix %s;\n", LEVEL, INDENT, module->prefix); |
Michal Vasko | 116172e | 2015-07-07 11:54:37 +0200 | [diff] [blame] | 1142 | } |
Radek Krejci | b0594bf | 2015-05-21 23:51:27 +0200 | [diff] [blame] | 1143 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1144 | /* linkage-stmts */ |
| 1145 | if (module->imp_size || module->inc_size) { |
| 1146 | ly_print(out, "\n"); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1147 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1148 | for (i = 0; i < module->imp_size; i++) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 1149 | if (module->imp[i].external) { |
| 1150 | continue; |
| 1151 | } |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1152 | ly_print(out, "%*simport \"%s\" {\n", LEVEL, INDENT, module->imp[i].module->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1153 | level++; |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1154 | ly_print(out, "%*sprefix %s;\n", LEVEL, INDENT, module->imp[i].prefix); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1155 | if (module->imp[i].rev[0]) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1156 | ly_print(out, "%*srevision-date %s;", LEVEL, INDENT, module->imp[i].rev); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1157 | } |
| 1158 | level--; |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1159 | ly_print(out, "%*s}", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1160 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1161 | for (i = 0; i < module->inc_size; i++) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 1162 | if (module->inc[i].external) { |
| 1163 | continue; |
| 1164 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1165 | if (module->inc[i].rev[0]) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1166 | ly_print(out, "%*sinclude \"%s\" {\n", LEVEL, INDENT, module->inc[i].submodule->name); |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1167 | level++; |
| 1168 | ly_print(out, "%*srevision-date %s;", LEVEL, INDENT, module->inc[i].rev); |
| 1169 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1170 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1171 | } else { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1172 | ly_print(out, "%*sinclude \"%s\";\n", LEVEL, INDENT, module->inc[i].submodule->name); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1173 | } |
| 1174 | } |
Radek Krejci | efaeba3 | 2015-05-27 14:30:57 +0200 | [diff] [blame] | 1175 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1176 | /* meta-stmts */ |
| 1177 | if (module->org || module->contact || module->dsc || module->ref) { |
| 1178 | ly_print(out, "\n"); |
| 1179 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1180 | if (module->org) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1181 | yang_print_text(out, level, "organization", module->org, 0); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1182 | } |
| 1183 | if (module->contact) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1184 | yang_print_text(out, level, "contact", module->contact, 0); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1185 | } |
| 1186 | if (module->dsc) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1187 | yang_print_text(out, level, "description", module->dsc, 0); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1188 | } |
| 1189 | if (module->ref) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1190 | yang_print_text(out, level, "reference", module->ref, 0); |
| 1191 | } |
| 1192 | |
| 1193 | /* revision-stmts */ |
| 1194 | if (module->rev_size) { |
| 1195 | ly_print(out, "\n"); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1196 | } |
| 1197 | for (i = 0; i < module->rev_size; i++) { |
| 1198 | if (module->rev[i].dsc || module->rev[i].ref) { |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1199 | ly_print(out, "%*srevision \"%s\" {\n", LEVEL, INDENT, module->rev[i].date); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1200 | level++; |
| 1201 | if (module->rev[i].dsc) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1202 | yang_print_text(out, level, "description", module->rev[i].dsc, 0); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1203 | } |
| 1204 | if (module->rev[i].ref) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1205 | yang_print_text(out, level, "reference", module->rev[i].ref, 0); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1206 | } |
| 1207 | level--; |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1208 | ly_print(out, "%*s}\n", LEVEL, INDENT); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1209 | } else { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1210 | ly_print(out, "%*srevision %s;", LEVEL, INDENT, module->rev[i].date); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1211 | } |
| 1212 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1213 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1214 | /* body-stmts */ |
Michal Vasko | 30f6e91 | 2015-07-07 12:24:27 +0200 | [diff] [blame] | 1215 | for (i = 0; i < module->features_size; i++) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1216 | ly_print(out, "\n"); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1217 | yang_print_feature(out, level, &module->features[i]); |
Michal Vasko | 30f6e91 | 2015-07-07 12:24:27 +0200 | [diff] [blame] | 1218 | } |
| 1219 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1220 | for (i = 0; i < module->ident_size; i++) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1221 | ly_print(out, "\n"); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1222 | yang_print_identity(out, level, &module->ident[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1223 | } |
Radek Krejci | 6793db0 | 2015-05-22 17:49:54 +0200 | [diff] [blame] | 1224 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1225 | for (i = 0; i < module->tpdf_size; i++) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1226 | ly_print(out, "\n"); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1227 | yang_print_typedef(out, level, module, &module->tpdf[i]); |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1228 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1229 | |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1230 | for (i = 0; i < module->deviation_size; ++i) { |
| 1231 | ly_print(out, "\n"); |
| 1232 | yang_print_deviation(out, level, module, &module->deviation[i]); |
| 1233 | } |
| 1234 | |
Radek Krejci | 1d82ef6 | 2015-08-07 14:44:40 +0200 | [diff] [blame] | 1235 | LY_TREE_FOR(module->data, node) { |
Radek Krejci | c071c54 | 2016-01-27 14:57:51 +0100 | [diff] [blame^] | 1236 | if (node->module != module) { |
| 1237 | continue; |
| 1238 | } |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1239 | ly_print(out, "\n"); |
Radek Krejci | 9272055 | 2015-10-05 15:28:27 +0200 | [diff] [blame] | 1240 | switch(node->nodetype) { |
| 1241 | case LYS_RPC: |
Radek Krejci | bac8176 | 2015-10-09 10:19:52 +0200 | [diff] [blame] | 1242 | yang_print_rpc(out, level, node); |
Radek Krejci | 9272055 | 2015-10-05 15:28:27 +0200 | [diff] [blame] | 1243 | break; |
| 1244 | case LYS_NOTIF: |
Radek Krejci | bac8176 | 2015-10-09 10:19:52 +0200 | [diff] [blame] | 1245 | yang_print_notif(out, level, node); |
Radek Krejci | 9272055 | 2015-10-05 15:28:27 +0200 | [diff] [blame] | 1246 | break; |
| 1247 | default: |
Radek Krejci | bac8176 | 2015-10-09 10:19:52 +0200 | [diff] [blame] | 1248 | yang_print_snode(out, level, node, |
Radek Krejci | 9272055 | 2015-10-05 15:28:27 +0200 | [diff] [blame] | 1249 | LYS_CHOICE | LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | |
| 1250 | LYS_USES | LYS_GROUPING | LYS_ANYXML); |
| 1251 | break; |
| 1252 | } |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1253 | } |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1254 | |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 1255 | for (i = 0; i < module->augment_size; i++) { |
Radek Krejci | 8d81e00 | 2015-12-10 11:18:59 +0100 | [diff] [blame] | 1256 | ly_print(out, "\n"); |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1257 | yang_print_augment(out, level, module, &module->augment[i]); |
Michal Vasko | 6f25f21 | 2015-07-07 15:42:07 +0200 | [diff] [blame] | 1258 | } |
| 1259 | |
Radek Krejci | 76b0790 | 2015-10-09 09:11:25 +0200 | [diff] [blame] | 1260 | ly_print(out, "}\n"); |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1261 | |
Radek Krejci | 6e4ffbb | 2015-06-16 10:34:41 +0200 | [diff] [blame] | 1262 | return EXIT_SUCCESS; |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 1263 | #undef LEVEL |
| 1264 | } |