Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file plugins_exts.c |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
Michal Vasko | ddd7659 | 2022-01-17 13:34:48 +0100 | [diff] [blame] | 4 | * @author Michal Vasko <mvasko@cesnet.cz> |
| 5 | * @brief helper functions for extension plugins |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 6 | * |
Michal Vasko | ddd7659 | 2022-01-17 13:34:48 +0100 | [diff] [blame] | 7 | * Copyright (c) 2019 - 2022 CESNET, z.s.p.o. |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 8 | * |
| 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * https://opensource.org/licenses/BSD-3-Clause |
| 14 | */ |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 15 | |
| 16 | #include "plugins_exts.h" |
| 17 | |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 18 | #include <assert.h> |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 19 | #include <stdint.h> |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 20 | #include <stdlib.h> |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 21 | |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 22 | #include "dict.h" |
Michal Vasko | 8f702ee | 2024-02-20 15:44:24 +0100 | [diff] [blame] | 23 | #include "ly_common.h" |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 24 | #include "parser_internal.h" |
Radek Krejci | f8d7f9a | 2021-03-10 14:32:36 +0100 | [diff] [blame] | 25 | #include "printer_internal.h" |
Radek Krejci | 5f9a367 | 2021-03-05 21:35:22 +0100 | [diff] [blame] | 26 | #include "schema_compile.h" |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 27 | #include "schema_compile_amend.h" |
| 28 | #include "schema_compile_node.h" |
| 29 | #include "schema_features.h" |
| 30 | #include "tree_schema_internal.h" |
| 31 | |
| 32 | LIBYANG_API_DEF const struct lysp_module * |
| 33 | lyplg_ext_parse_get_cur_pmod(const struct lysp_ctx *pctx) |
| 34 | { |
| 35 | return PARSER_CUR_PMOD(pctx); |
| 36 | } |
| 37 | |
| 38 | LIBYANG_API_DEF LY_ERR |
| 39 | lyplg_ext_parse_extension_instance(struct lysp_ctx *pctx, struct lysp_ext_instance *ext) |
| 40 | { |
| 41 | LY_ERR rc = LY_SUCCESS; |
| 42 | LY_ARRAY_COUNT_TYPE u; |
| 43 | struct lysp_stmt *stmt; |
| 44 | |
| 45 | /* check for invalid substatements */ |
| 46 | LY_LIST_FOR(ext->child, stmt) { |
| 47 | if (stmt->flags & (LYS_YIN_ATTR | LYS_YIN_ARGUMENT)) { |
| 48 | continue; |
| 49 | } |
| 50 | LY_ARRAY_FOR(ext->substmts, u) { |
| 51 | if (ext->substmts[u].stmt == stmt->kw) { |
| 52 | break; |
| 53 | } |
| 54 | } |
| 55 | if (u == LY_ARRAY_COUNT(ext->substmts)) { |
| 56 | LOGVAL(PARSER_CTX(pctx), LYVE_SYNTAX_YANG, "Invalid keyword \"%s\" as a child of \"%s%s%s\" extension instance.", |
| 57 | stmt->stmt, ext->name, ext->argument ? " " : "", ext->argument ? ext->argument : ""); |
| 58 | rc = LY_EVALID; |
| 59 | goto cleanup; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /* parse all the known statements */ |
| 64 | LY_ARRAY_FOR(ext->substmts, u) { |
| 65 | LY_LIST_FOR(ext->child, stmt) { |
| 66 | if (ext->substmts[u].stmt != stmt->kw) { |
| 67 | continue; |
| 68 | } |
| 69 | |
| 70 | if ((rc = lys_parse_ext_instance_stmt(pctx, &ext->substmts[u], stmt))) { |
| 71 | goto cleanup; |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | cleanup: |
| 77 | return rc; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @brief Compile an instance extension statement. |
| 82 | * |
| 83 | * @param[in] ctx Compile context. |
| 84 | * @param[in] parsed Parsed ext instance substatement structure. |
| 85 | * @param[in] ext Compiled ext instance. |
| 86 | * @param[in] substmt Compled ext instance substatement info. |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 87 | * @return LY_ERR value. |
| 88 | */ |
| 89 | static LY_ERR |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 90 | lys_compile_ext_instance_stmt(struct lysc_ctx *ctx, uint64_t parsed, struct lysc_ext_instance *ext, |
Michal Vasko | a0ba01e | 2022-10-19 13:26:57 +0200 | [diff] [blame] | 91 | struct lysc_ext_substmt *substmt) |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 92 | { |
| 93 | LY_ERR rc = LY_SUCCESS; |
| 94 | ly_bool length_restr = 0; |
| 95 | LY_DATA_TYPE basetype; |
| 96 | |
Michal Vasko | d595eff | 2023-02-20 11:29:28 +0100 | [diff] [blame] | 97 | assert(parsed); |
| 98 | |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 99 | /* compilation wthout any storage */ |
| 100 | if (substmt->stmt == LY_STMT_IF_FEATURE) { |
| 101 | ly_bool enabled; |
| 102 | |
| 103 | /* evaluate */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 104 | LY_CHECK_GOTO(rc = lys_eval_iffeatures(ctx->ctx, VOIDPTR_C(parsed), &enabled), cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 105 | if (!enabled) { |
| 106 | /* it is disabled, remove the whole extension instance */ |
| 107 | rc = LY_ENOT; |
| 108 | } |
| 109 | } |
| 110 | |
Michal Vasko | d595eff | 2023-02-20 11:29:28 +0100 | [diff] [blame] | 111 | if (!substmt->storage) { |
| 112 | /* nothing to store */ |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 113 | goto cleanup; |
| 114 | } |
| 115 | |
| 116 | switch (substmt->stmt) { |
| 117 | case LY_STMT_NOTIFICATION: |
| 118 | case LY_STMT_INPUT: |
| 119 | case LY_STMT_OUTPUT: |
| 120 | case LY_STMT_ACTION: |
| 121 | case LY_STMT_RPC: |
| 122 | case LY_STMT_ANYDATA: |
| 123 | case LY_STMT_ANYXML: |
| 124 | case LY_STMT_CASE: |
| 125 | case LY_STMT_CHOICE: |
| 126 | case LY_STMT_CONTAINER: |
| 127 | case LY_STMT_LEAF: |
| 128 | case LY_STMT_LEAF_LIST: |
| 129 | case LY_STMT_LIST: |
| 130 | case LY_STMT_USES: { |
| 131 | const uint16_t flags; |
| 132 | struct lysp_node *pnodes, *pnode; |
| 133 | struct lysc_node *node; |
| 134 | |
Michal Vasko | fbd037c | 2022-11-08 10:34:20 +0100 | [diff] [blame] | 135 | lyplg_ext_get_storage(ext, LY_STMT_STATUS, sizeof flags, (const void **)&flags); |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 136 | pnodes = VOIDPTR_C(parsed); |
Michal Vasko | a0ba01e | 2022-10-19 13:26:57 +0200 | [diff] [blame] | 137 | |
| 138 | /* compile nodes */ |
| 139 | LY_LIST_FOR(pnodes, pnode) { |
| 140 | if (pnode->nodetype & (LYS_INPUT | LYS_OUTPUT)) { |
| 141 | /* manual compile */ |
| 142 | node = calloc(1, sizeof(struct lysc_node_action_inout)); |
| 143 | LY_CHECK_ERR_GOTO(!node, LOGMEM(ctx->ctx); rc = LY_EMEM, cleanup); |
| 144 | LY_CHECK_GOTO(rc = lys_compile_node_action_inout(ctx, pnode, node), cleanup); |
| 145 | LY_CHECK_GOTO(rc = lys_compile_node_connect(ctx, NULL, node), cleanup); |
| 146 | } else { |
| 147 | /* ctx->ext substatement storage is used as the document root */ |
| 148 | LY_CHECK_GOTO(rc = lys_compile_node(ctx, pnode, NULL, flags, NULL), cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 149 | } |
| 150 | } |
| 151 | break; |
| 152 | } |
| 153 | case LY_STMT_ARGUMENT: |
| 154 | case LY_STMT_CONTACT: |
| 155 | case LY_STMT_DESCRIPTION: |
| 156 | case LY_STMT_ERROR_APP_TAG: |
| 157 | case LY_STMT_ERROR_MESSAGE: |
| 158 | case LY_STMT_KEY: |
| 159 | case LY_STMT_MODIFIER: |
| 160 | case LY_STMT_NAMESPACE: |
| 161 | case LY_STMT_ORGANIZATION: |
| 162 | case LY_STMT_PRESENCE: |
| 163 | case LY_STMT_REFERENCE: |
| 164 | case LY_STMT_UNITS: |
| 165 | /* just make a copy */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 166 | LY_CHECK_GOTO(rc = lydict_insert(ctx->ctx, VOIDPTR_C(parsed), 0, VOIDPTR_C(substmt->storage)), cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 167 | break; |
| 168 | |
| 169 | case LY_STMT_BIT: |
| 170 | basetype = LY_TYPE_BITS; |
| 171 | /* fallthrough */ |
| 172 | case LY_STMT_ENUM: |
| 173 | if (substmt->stmt == LY_STMT_ENUM) { |
| 174 | basetype = LY_TYPE_ENUM; |
| 175 | } |
| 176 | |
| 177 | /* compile */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 178 | rc = lys_compile_type_enums(ctx, VOIDPTR_C(parsed), basetype, NULL, VOIDPTR_C(substmt->storage)); |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 179 | LY_CHECK_GOTO(rc, cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 180 | break; |
| 181 | |
| 182 | case LY_STMT_CONFIG: { |
Michal Vasko | 118eb52 | 2023-01-12 11:04:51 +0100 | [diff] [blame] | 183 | uint16_t flags; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 184 | |
| 185 | if (!(ctx->compile_opts & LYS_COMPILE_NO_CONFIG)) { |
Michal Vasko | 118eb52 | 2023-01-12 11:04:51 +0100 | [diff] [blame] | 186 | memcpy(&flags, &parsed, 2); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 187 | if (flags & LYS_CONFIG_MASK) { |
| 188 | /* explicitly set */ |
Michal Vasko | 118eb52 | 2023-01-12 11:04:51 +0100 | [diff] [blame] | 189 | flags |= LYS_SET_CONFIG; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 190 | } else if (ext->parent_stmt & LY_STMT_DATA_NODE_MASK) { |
| 191 | /* inherit */ |
Michal Vasko | 118eb52 | 2023-01-12 11:04:51 +0100 | [diff] [blame] | 192 | flags = ((struct lysc_node *)ext->parent)->flags & LYS_CONFIG_MASK; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 193 | } else { |
| 194 | /* default config */ |
Michal Vasko | 118eb52 | 2023-01-12 11:04:51 +0100 | [diff] [blame] | 195 | flags = LYS_CONFIG_W; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 196 | } |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 197 | memcpy(VOIDPTR_C(substmt->storage), &flags, 2); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 198 | } /* else leave zero */ |
| 199 | break; |
| 200 | } |
| 201 | case LY_STMT_MUST: { |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 202 | const struct lysp_restr *restrs = VOIDPTR_C(parsed); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 203 | |
| 204 | /* sized array */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 205 | COMPILE_ARRAY_GOTO(ctx, restrs, *(struct lysc_must **)VOIDPTR_C(substmt->storage), lys_compile_must, rc, cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 206 | break; |
| 207 | } |
| 208 | case LY_STMT_WHEN: { |
| 209 | const uint16_t flags; |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 210 | const struct lysp_when *when = VOIDPTR_C(parsed); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 211 | |
| 212 | /* read compiled status */ |
Michal Vasko | fbd037c | 2022-11-08 10:34:20 +0100 | [diff] [blame] | 213 | lyplg_ext_get_storage(ext, LY_STMT_STATUS, sizeof flags, (const void **)&flags); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 214 | |
| 215 | /* compile */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 216 | LY_CHECK_GOTO(rc = lys_compile_when(ctx, when, flags, NULL, NULL, NULL, VOIDPTR_C(substmt->storage)), cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 217 | break; |
| 218 | } |
| 219 | case LY_STMT_FRACTION_DIGITS: |
| 220 | case LY_STMT_REQUIRE_INSTANCE: |
| 221 | /* just make a copy */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 222 | memcpy(VOIDPTR_C(substmt->storage), &parsed, 1); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 223 | break; |
| 224 | |
| 225 | case LY_STMT_MANDATORY: |
| 226 | case LY_STMT_ORDERED_BY: |
| 227 | case LY_STMT_STATUS: |
| 228 | /* just make a copy */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 229 | memcpy(VOIDPTR_C(substmt->storage), &parsed, 2); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 230 | break; |
| 231 | |
| 232 | case LY_STMT_MAX_ELEMENTS: |
| 233 | case LY_STMT_MIN_ELEMENTS: |
| 234 | /* just make a copy */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 235 | memcpy(VOIDPTR_C(substmt->storage), &parsed, 4); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 236 | break; |
| 237 | |
| 238 | case LY_STMT_POSITION: |
| 239 | case LY_STMT_VALUE: |
| 240 | /* just make a copy */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 241 | memcpy(VOIDPTR_C(substmt->storage), &parsed, 8); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 242 | break; |
| 243 | |
| 244 | case LY_STMT_IDENTITY: |
| 245 | /* compile */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 246 | rc = lys_identity_precompile(ctx, NULL, NULL, VOIDPTR_C(parsed), VOIDPTR_C(substmt->storage)); |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 247 | LY_CHECK_GOTO(rc, cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 248 | break; |
| 249 | |
| 250 | case LY_STMT_LENGTH: |
| 251 | length_restr = 1; |
| 252 | /* fallthrough */ |
| 253 | case LY_STMT_RANGE: |
| 254 | /* compile, use uint64 default range */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 255 | rc = lys_compile_type_range(ctx, VOIDPTR_C(parsed), LY_TYPE_UINT64, length_restr, 0, NULL, VOIDPTR_C(substmt->storage)); |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 256 | LY_CHECK_GOTO(rc, cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 257 | break; |
| 258 | |
| 259 | case LY_STMT_PATTERN: |
| 260 | /* compile */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 261 | rc = lys_compile_type_patterns(ctx, VOIDPTR_C(parsed), NULL, VOIDPTR_C(substmt->storage)); |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 262 | LY_CHECK_GOTO(rc, cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 263 | break; |
| 264 | |
| 265 | case LY_STMT_TYPE: { |
| 266 | const uint16_t flags; |
| 267 | const char *units; |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 268 | const struct lysp_type *ptype = VOIDPTR_C(parsed); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 269 | |
| 270 | /* read compiled info */ |
Michal Vasko | fbd037c | 2022-11-08 10:34:20 +0100 | [diff] [blame] | 271 | lyplg_ext_get_storage(ext, LY_STMT_STATUS, sizeof flags, (const void **)&flags); |
| 272 | lyplg_ext_get_storage(ext, LY_STMT_UNITS, sizeof units, (const void **)&units); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 273 | |
| 274 | /* compile */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 275 | rc = lys_compile_type(ctx, NULL, flags, ext->def->name, ptype, VOIDPTR_C(substmt->storage), &units, NULL); |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 276 | LY_CHECK_GOTO(rc, cleanup); |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 277 | LY_ATOMIC_INC_BARRIER((*(struct lysc_type **)VOIDPTR_C(substmt->storage))->refcount); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 278 | break; |
| 279 | } |
| 280 | case LY_STMT_EXTENSION_INSTANCE: { |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 281 | struct lysp_ext_instance *extps = VOIDPTR_C(parsed); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 282 | |
| 283 | /* compile sized array */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 284 | COMPILE_EXTS_GOTO(ctx, extps, *(struct lysc_ext_instance **)VOIDPTR_C(substmt->storage), ext, rc, cleanup); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 285 | break; |
| 286 | } |
| 287 | case LY_STMT_AUGMENT: |
| 288 | case LY_STMT_GROUPING: |
| 289 | case LY_STMT_BASE: |
| 290 | case LY_STMT_BELONGS_TO: |
| 291 | case LY_STMT_DEFAULT: |
| 292 | case LY_STMT_DEVIATE: |
| 293 | case LY_STMT_DEVIATION: |
| 294 | case LY_STMT_EXTENSION: |
| 295 | case LY_STMT_FEATURE: |
| 296 | case LY_STMT_IF_FEATURE: |
| 297 | case LY_STMT_IMPORT: |
| 298 | case LY_STMT_INCLUDE: |
| 299 | case LY_STMT_MODULE: |
| 300 | case LY_STMT_PATH: |
| 301 | case LY_STMT_PREFIX: |
| 302 | case LY_STMT_REFINE: |
| 303 | case LY_STMT_REVISION: |
| 304 | case LY_STMT_REVISION_DATE: |
| 305 | case LY_STMT_SUBMODULE: |
| 306 | case LY_STMT_TYPEDEF: |
| 307 | case LY_STMT_UNIQUE: |
| 308 | case LY_STMT_YANG_VERSION: |
| 309 | case LY_STMT_YIN_ELEMENT: |
| 310 | LOGVAL(ctx->ctx, LYVE_SYNTAX_YANG, "Statement \"%s\" compilation is not supported.", lyplg_ext_stmt2str(substmt->stmt)); |
| 311 | rc = LY_EVALID; |
| 312 | goto cleanup; |
| 313 | |
| 314 | default: |
| 315 | LOGVAL(ctx->ctx, LYVE_SYNTAX_YANG, "Statement \"%s\" is not supported as an extension " |
| 316 | "(found in \"%s%s%s\") substatement.", lyplg_ext_stmt2str(substmt->stmt), ext->def->name, |
| 317 | ext->argument ? " " : "", ext->argument ? ext->argument : ""); |
| 318 | rc = LY_EVALID; |
| 319 | goto cleanup; |
| 320 | } |
| 321 | |
| 322 | cleanup: |
| 323 | return rc; |
| 324 | } |
| 325 | |
Michal Vasko | a0ba01e | 2022-10-19 13:26:57 +0200 | [diff] [blame] | 326 | LIBYANG_API_DEF LY_ERR |
| 327 | lyplg_ext_compile_extension_instance(struct lysc_ctx *ctx, const struct lysp_ext_instance *extp, |
| 328 | struct lysc_ext_instance *ext) |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 329 | { |
| 330 | LY_ERR rc = LY_SUCCESS; |
| 331 | LY_ARRAY_COUNT_TYPE u, v; |
| 332 | enum ly_stmt stmtp; |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 333 | uint64_t storagep; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 334 | struct ly_set storagep_compiled = {0}; |
| 335 | |
Michal Vasko | a0ba01e | 2022-10-19 13:26:57 +0200 | [diff] [blame] | 336 | LY_CHECK_ARG_RET(ctx ? ctx->ctx : NULL, ctx, extp, ext, LY_EINVAL); |
| 337 | |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 338 | /* note into the compile context that we are processing extension now */ |
| 339 | ctx->ext = ext; |
| 340 | |
| 341 | LY_ARRAY_FOR(extp->substmts, u) { |
| 342 | stmtp = extp->substmts[u].stmt; |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 343 | storagep = *(uint64_t *)VOIDPTR_C(extp->substmts[u].storage); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 344 | |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 345 | if (!storagep || ly_set_contains(&storagep_compiled, VOIDPTR_C(storagep), NULL)) { |
Michal Vasko | d595eff | 2023-02-20 11:29:28 +0100 | [diff] [blame] | 346 | /* nothing parsed or already compiled (for example, if it is a linked list of parsed nodes) */ |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 347 | continue; |
| 348 | } |
| 349 | |
| 350 | LY_ARRAY_FOR(ext->substmts, v) { |
| 351 | if (stmtp != ext->substmts[v].stmt) { |
| 352 | continue; |
| 353 | } |
| 354 | |
Michal Vasko | a0ba01e | 2022-10-19 13:26:57 +0200 | [diff] [blame] | 355 | if ((rc = lys_compile_ext_instance_stmt(ctx, storagep, ext, &ext->substmts[v]))) { |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 356 | goto cleanup; |
| 357 | } |
| 358 | |
| 359 | /* parsed substatement compiled */ |
| 360 | break; |
| 361 | } |
| 362 | |
| 363 | /* compiled */ |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 364 | ly_set_add(&storagep_compiled, VOIDPTR_C(storagep), 1, NULL); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | cleanup: |
| 368 | ctx->ext = NULL; |
| 369 | ly_set_erase(&storagep_compiled, NULL); |
| 370 | return rc; |
| 371 | } |
| 372 | |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 373 | LIBYANG_API_DEF struct ly_ctx * |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 374 | lyplg_ext_compile_get_ctx(const struct lysc_ctx *ctx) |
Radek Krejci | 5f9a367 | 2021-03-05 21:35:22 +0100 | [diff] [blame] | 375 | { |
| 376 | return ctx->ctx; |
| 377 | } |
| 378 | |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 379 | LIBYANG_API_DEF uint32_t * |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 380 | lyplg_ext_compile_get_options(const struct lysc_ctx *ctx) |
Radek Krejci | 5f9a367 | 2021-03-05 21:35:22 +0100 | [diff] [blame] | 381 | { |
Michal Vasko | 7c56592 | 2021-06-10 14:58:27 +0200 | [diff] [blame] | 382 | return &((struct lysc_ctx *)ctx)->compile_opts; |
Radek Krejci | 5f9a367 | 2021-03-05 21:35:22 +0100 | [diff] [blame] | 383 | } |
| 384 | |
Michal Vasko | 6a914fb | 2022-01-17 10:36:14 +0100 | [diff] [blame] | 385 | LIBYANG_API_DEF const struct lys_module * |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 386 | lyplg_ext_compile_get_cur_mod(const struct lysc_ctx *ctx) |
tadeas-vintrlik | 2aa36b4 | 2021-11-03 13:07:34 +0100 | [diff] [blame] | 387 | { |
| 388 | return ctx->cur_mod; |
| 389 | } |
| 390 | |
Michal Vasko | 6a914fb | 2022-01-17 10:36:14 +0100 | [diff] [blame] | 391 | LIBYANG_API_DEF struct lysp_module * |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 392 | lyplg_ext_compile_get_pmod(const struct lysc_ctx *ctx) |
tadeas-vintrlik | 2aa36b4 | 2021-11-03 13:07:34 +0100 | [diff] [blame] | 393 | { |
| 394 | return ctx->pmod; |
| 395 | } |
Michal Vasko | ddd7659 | 2022-01-17 13:34:48 +0100 | [diff] [blame] | 396 | |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 397 | LIBYANG_API_DEF struct ly_out ** |
| 398 | lyplg_ext_print_get_out(const struct lyspr_ctx *ctx) |
| 399 | { |
| 400 | return &((struct lyspr_ctx *)ctx)->out; |
| 401 | } |
| 402 | |
| 403 | LIBYANG_API_DEF uint32_t * |
| 404 | lyplg_ext_print_get_options(const struct lyspr_ctx *ctx) |
| 405 | { |
| 406 | return &((struct lyspr_ctx *)ctx)->options; |
| 407 | } |
| 408 | |
| 409 | LIBYANG_API_DEF uint16_t * |
| 410 | lyplg_ext_print_get_level(const struct lyspr_ctx *ctx) |
| 411 | { |
| 412 | return &((struct lyspr_ctx *)ctx)->level; |
| 413 | } |
| 414 | |
aPiecek | 03cb487 | 2022-10-24 10:31:51 +0200 | [diff] [blame] | 415 | LIBYANG_API_DECL LY_ERR |
| 416 | lyplg_ext_sprinter_ctree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct lysc_ext_instance *ext, |
| 417 | lyplg_ext_sprinter_ctree_override_clb clb) |
| 418 | { |
| 419 | LY_ERR rc = LY_SUCCESS; |
| 420 | uint32_t i; |
| 421 | struct lysc_node *schema; |
| 422 | |
| 423 | LY_CHECK_ARG_RET2(NULL, ctx, ext, LY_EINVAL); |
| 424 | |
| 425 | LY_ARRAY_FOR(ext->substmts, i) { |
| 426 | switch (ext->substmts[i].stmt) { |
| 427 | case LY_STMT_NOTIFICATION: |
| 428 | case LY_STMT_INPUT: |
| 429 | case LY_STMT_OUTPUT: |
| 430 | case LY_STMT_ACTION: |
| 431 | case LY_STMT_RPC: |
| 432 | case LY_STMT_ANYDATA: |
| 433 | case LY_STMT_ANYXML: |
| 434 | case LY_STMT_CASE: |
| 435 | case LY_STMT_CHOICE: |
| 436 | case LY_STMT_CONTAINER: |
| 437 | case LY_STMT_LEAF: |
| 438 | case LY_STMT_LEAF_LIST: |
| 439 | case LY_STMT_LIST: |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 440 | schema = *VOIDPTR2_C(ext->substmts[i].storage); |
aPiecek | 03cb487 | 2022-10-24 10:31:51 +0200 | [diff] [blame] | 441 | if (schema) { |
| 442 | rc = lyplg_ext_sprinter_ctree_add_nodes(ctx, schema, clb); |
| 443 | return rc; |
| 444 | } |
| 445 | default: |
| 446 | break; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | return rc; |
| 451 | } |
| 452 | |
| 453 | LIBYANG_API_DECL LY_ERR |
| 454 | lyplg_ext_sprinter_ptree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct lysp_ext_instance *ext, |
| 455 | lyplg_ext_sprinter_ptree_override_clb clb) |
| 456 | { |
| 457 | LY_ERR rc = LY_SUCCESS; |
| 458 | uint32_t i; |
| 459 | struct lysp_node *schema; |
| 460 | |
| 461 | LY_CHECK_ARG_RET2(NULL, ctx, ext, LY_EINVAL); |
| 462 | |
| 463 | LY_ARRAY_FOR(ext->substmts, i) { |
| 464 | switch (ext->substmts[i].stmt) { |
| 465 | case LY_STMT_NOTIFICATION: |
| 466 | case LY_STMT_INPUT: |
| 467 | case LY_STMT_OUTPUT: |
| 468 | case LY_STMT_ACTION: |
| 469 | case LY_STMT_RPC: |
| 470 | case LY_STMT_ANYDATA: |
| 471 | case LY_STMT_ANYXML: |
| 472 | case LY_STMT_CASE: |
| 473 | case LY_STMT_CHOICE: |
| 474 | case LY_STMT_CONTAINER: |
| 475 | case LY_STMT_LEAF: |
| 476 | case LY_STMT_LEAF_LIST: |
| 477 | case LY_STMT_LIST: |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 478 | schema = *VOIDPTR2_C(ext->substmts[i].storage); |
aPiecek | 03cb487 | 2022-10-24 10:31:51 +0200 | [diff] [blame] | 479 | if (schema) { |
| 480 | rc = lyplg_ext_sprinter_ptree_add_nodes(ctx, schema, clb); |
| 481 | return rc; |
| 482 | } |
| 483 | default: |
| 484 | break; |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | return rc; |
| 489 | } |
| 490 | |
| 491 | LIBYANG_API_DECL LY_ERR |
| 492 | lyplg_ext_sprinter_ctree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysc_node *nodes, |
| 493 | lyplg_ext_sprinter_ctree_override_clb clb) |
| 494 | { |
| 495 | struct lyspr_tree_schema *new; |
| 496 | |
| 497 | LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL); |
| 498 | |
| 499 | if (!nodes) { |
| 500 | return LY_SUCCESS; |
| 501 | } |
| 502 | |
| 503 | LY_ARRAY_NEW_RET(NULL, ((struct lyspr_tree_ctx *)ctx)->schemas, new, LY_EMEM); |
| 504 | new->compiled = 1; |
| 505 | new->ctree = nodes; |
| 506 | new->cn_overr = clb; |
| 507 | |
| 508 | return LY_SUCCESS; |
| 509 | } |
| 510 | |
| 511 | LIBYANG_API_DECL LY_ERR |
| 512 | lyplg_ext_sprinter_ptree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysp_node *nodes, |
| 513 | lyplg_ext_sprinter_ptree_override_clb clb) |
| 514 | { |
| 515 | struct lyspr_tree_schema *new; |
| 516 | |
| 517 | LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL); |
| 518 | |
| 519 | if (!nodes) { |
| 520 | return LY_SUCCESS; |
| 521 | } |
| 522 | |
| 523 | LY_ARRAY_NEW_RET(NULL, ((struct lyspr_tree_ctx *)ctx)->schemas, new, LY_EMEM); |
| 524 | new->compiled = 0; |
| 525 | new->ptree = nodes; |
| 526 | new->pn_overr = clb; |
| 527 | |
| 528 | return LY_SUCCESS; |
| 529 | } |
| 530 | |
| 531 | LIBYANG_API_DECL LY_ERR |
| 532 | lyplg_ext_sprinter_tree_set_priv(const struct lyspr_tree_ctx *ctx, void *plugin_priv, void (*free_clb)(void *plugin_priv)) |
| 533 | { |
| 534 | LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL); |
| 535 | |
| 536 | ((struct lyspr_tree_ctx *)ctx)->plugin_priv = plugin_priv; |
| 537 | ((struct lyspr_tree_ctx *)ctx)->free_plugin_priv = free_clb; |
| 538 | |
| 539 | return LY_SUCCESS; |
| 540 | } |
| 541 | |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 542 | LIBYANG_API_DEF const char * |
| 543 | lyplg_ext_stmt2str(enum ly_stmt stmt) |
| 544 | { |
| 545 | if (stmt == LY_STMT_EXTENSION_INSTANCE) { |
| 546 | return "extension instance"; |
| 547 | } else { |
Michal Vasko | b872d0f | 2022-12-08 09:36:54 +0100 | [diff] [blame] | 548 | return lys_stmt_str(stmt); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 549 | } |
| 550 | } |
| 551 | |
| 552 | LIBYANG_API_DEF enum ly_stmt |
| 553 | lyplg_ext_nodetype2stmt(uint16_t nodetype) |
| 554 | { |
| 555 | switch (nodetype) { |
| 556 | case LYS_CONTAINER: |
| 557 | return LY_STMT_CONTAINER; |
| 558 | case LYS_CHOICE: |
| 559 | return LY_STMT_CHOICE; |
| 560 | case LYS_LEAF: |
| 561 | return LY_STMT_LEAF; |
| 562 | case LYS_LEAFLIST: |
| 563 | return LY_STMT_LEAF_LIST; |
| 564 | case LYS_LIST: |
| 565 | return LY_STMT_LIST; |
| 566 | case LYS_ANYXML: |
| 567 | return LY_STMT_ANYXML; |
| 568 | case LYS_ANYDATA: |
| 569 | return LY_STMT_ANYDATA; |
| 570 | case LYS_CASE: |
| 571 | return LY_STMT_CASE; |
| 572 | case LYS_RPC: |
| 573 | return LY_STMT_RPC; |
| 574 | case LYS_ACTION: |
| 575 | return LY_STMT_ACTION; |
| 576 | case LYS_NOTIF: |
| 577 | return LY_STMT_NOTIFICATION; |
| 578 | case LYS_USES: |
| 579 | return LY_STMT_USES; |
| 580 | case LYS_INPUT: |
| 581 | return LY_STMT_INPUT; |
| 582 | case LYS_OUTPUT: |
| 583 | return LY_STMT_OUTPUT; |
| 584 | default: |
| 585 | return LY_STMT_NONE; |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | LY_ERR |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 590 | lyplg_ext_get_storage_p(const struct lysc_ext_instance *ext, int stmt, uint64_t *storage_p) |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 591 | { |
| 592 | LY_ARRAY_COUNT_TYPE u; |
| 593 | enum ly_stmt match = 0; |
| 594 | |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 595 | *storage_p = 0; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 596 | |
| 597 | if (!(stmt & LY_STMT_NODE_MASK)) { |
| 598 | /* matching a non-node statement */ |
| 599 | match = stmt; |
| 600 | } |
| 601 | |
| 602 | LY_ARRAY_FOR(ext->substmts, u) { |
| 603 | if ((match && (ext->substmts[u].stmt == match)) || (!match && (ext->substmts[u].stmt & stmt))) { |
| 604 | *storage_p = ext->substmts[u].storage; |
| 605 | return LY_SUCCESS; |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | return LY_ENOT; |
| 610 | } |
| 611 | |
| 612 | LIBYANG_API_DEF LY_ERR |
Michal Vasko | fbd037c | 2022-11-08 10:34:20 +0100 | [diff] [blame] | 613 | lyplg_ext_get_storage(const struct lysc_ext_instance *ext, int stmt, uint32_t storage_size, const void **storage) |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 614 | { |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 615 | LY_ERR rc = LY_SUCCESS; |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 616 | uint64_t s; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 617 | |
Michal Vasko | 250ffba | 2022-11-08 11:31:05 +0100 | [diff] [blame] | 618 | /* get pointer to the storage, is set even on error */ |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 619 | rc = lyplg_ext_get_storage_p(ext, stmt, &s); |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 620 | |
Michal Vasko | 250ffba | 2022-11-08 11:31:05 +0100 | [diff] [blame] | 621 | /* assign */ |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 622 | if (s) { |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 623 | memcpy(storage, VOIDPTR_C(s), storage_size); |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 624 | } else { |
| 625 | memset(storage, 0, storage_size); |
| 626 | } |
| 627 | |
| 628 | return rc; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | LIBYANG_API_DEF LY_ERR |
Michal Vasko | fbd037c | 2022-11-08 10:34:20 +0100 | [diff] [blame] | 632 | lyplg_ext_parsed_get_storage(const struct lysc_ext_instance *ext, int stmt, uint32_t storage_size, const void **storage) |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 633 | { |
| 634 | LY_ARRAY_COUNT_TYPE u; |
| 635 | const struct lysp_ext_instance *extp = NULL; |
| 636 | enum ly_stmt match = 0; |
Michal Vasko | 708a8bf | 2024-06-13 09:44:51 +0200 | [diff] [blame] | 637 | uint64_t s = 0; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 638 | |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 639 | /* find the parsed ext instance */ |
| 640 | LY_ARRAY_FOR(ext->module->parsed->exts, u) { |
| 641 | extp = &ext->module->parsed->exts[u]; |
| 642 | |
| 643 | if (ext->def == extp->def->compiled) { |
| 644 | break; |
| 645 | } |
| 646 | extp = NULL; |
| 647 | } |
| 648 | assert(extp); |
| 649 | |
| 650 | if (!(stmt & LY_STMT_NODE_MASK)) { |
| 651 | /* matching a non-node statement */ |
| 652 | match = stmt; |
| 653 | } |
| 654 | |
| 655 | /* get the substatement */ |
| 656 | LY_ARRAY_FOR(extp->substmts, u) { |
| 657 | if ((match && (extp->substmts[u].stmt == match)) || (!match && (extp->substmts[u].stmt & stmt))) { |
Michal Vasko | fbd037c | 2022-11-08 10:34:20 +0100 | [diff] [blame] | 658 | s = extp->substmts[u].storage; |
| 659 | break; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 660 | } |
| 661 | } |
| 662 | |
Michal Vasko | 250ffba | 2022-11-08 11:31:05 +0100 | [diff] [blame] | 663 | /* assign */ |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 664 | if (s) { |
Michal Vasko | 53eb6a1 | 2024-06-13 11:38:47 +0200 | [diff] [blame] | 665 | memcpy(storage, VOIDPTR_C(s), storage_size); |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame] | 666 | } else { |
| 667 | memset(storage, 0, storage_size); |
| 668 | } |
| 669 | |
| 670 | return LY_SUCCESS; |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 671 | } |
| 672 | |
Michal Vasko | ddd7659 | 2022-01-17 13:34:48 +0100 | [diff] [blame] | 673 | LIBYANG_API_DEF LY_ERR |
| 674 | lyplg_ext_get_data(const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, void **ext_data, ly_bool *ext_data_free) |
| 675 | { |
Michal Vasko | 40a7a44 | 2022-12-09 13:01:38 +0100 | [diff] [blame] | 676 | LY_ERR rc; |
| 677 | |
Michal Vasko | ddd7659 | 2022-01-17 13:34:48 +0100 | [diff] [blame] | 678 | if (!ctx->ext_clb) { |
Michal Vasko | 193dacd | 2022-10-13 08:43:05 +0200 | [diff] [blame] | 679 | lyplg_ext_compile_log(NULL, ext, LY_LLERR, LY_EINVAL, "Failed to get extension data, no callback set."); |
Michal Vasko | ddd7659 | 2022-01-17 13:34:48 +0100 | [diff] [blame] | 680 | return LY_EINVAL; |
| 681 | } |
| 682 | |
Michal Vasko | 40a7a44 | 2022-12-09 13:01:38 +0100 | [diff] [blame] | 683 | if ((rc = ctx->ext_clb(ext, ctx->ext_clb_data, ext_data, ext_data_free))) { |
| 684 | lyplg_ext_compile_log(NULL, ext, LY_LLERR, rc, "Callback for getting ext data failed."); |
| 685 | } |
| 686 | return rc; |
Michal Vasko | ddd7659 | 2022-01-17 13:34:48 +0100 | [diff] [blame] | 687 | } |