Radek Krejci | 04699f0 | 2021-03-22 21:50:29 +0100 | [diff] [blame] | 1 | /** |
| 2 | * @file plugins_internal.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 4 | * @author Michal Vasko <mvasko@cesnet.cz> |
Radek Krejci | 04699f0 | 2021-03-22 21:50:29 +0100 | [diff] [blame] | 5 | * @brief internal functions to support extension and type plugins. |
| 6 | * |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 7 | * Copyright (c) 2019-2022 CESNET, z.s.p.o. |
Radek Krejci | 04699f0 | 2021-03-22 21:50:29 +0100 | [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 | */ |
| 15 | |
| 16 | #ifndef LY_PLUGINS_INTERNAL_H_ |
| 17 | #define LY_PLUGINS_INTERNAL_H_ |
| 18 | |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 19 | #include <stdint.h> |
| 20 | |
| 21 | #include "plugins.h" |
| 22 | #include "plugins_exts.h" |
aPiecek | 704f8e9 | 2021-08-25 13:35:05 +0200 | [diff] [blame] | 23 | #include "plugins_types.h" |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 24 | |
Radek Krejci | 04699f0 | 2021-03-22 21:50:29 +0100 | [diff] [blame] | 25 | #define LY_TYPE_UNKNOWN_STR "unknown" /**< text representation of ::LY_TYPE_UNKNOWN */ |
| 26 | #define LY_TYPE_BINARY_STR "binary" /**< text representation of ::LY_TYPE_BINARY */ |
| 27 | #define LY_TYPE_UINT8_STR "8bit unsigned integer" /**< text representation of ::LY_TYPE_UINT8 */ |
| 28 | #define LY_TYPE_UINT16_STR "16bit unsigned integer" /**< text representation of ::LY_TYPE_UINT16 */ |
| 29 | #define LY_TYPE_UINT32_STR "32bit unsigned integer" /**< text representation of ::LY_TYPE_UINT32 */ |
| 30 | #define LY_TYPE_UINT64_STR "64bit unsigned integer" /**< text representation of ::LY_TYPE_UINT64 */ |
| 31 | #define LY_TYPE_STRING_STR "string" /**< text representation of ::LY_TYPE_STRING */ |
| 32 | #define LY_TYPE_BITS_STR "bits" /**< text representation of ::LY_TYPE_BITS */ |
| 33 | #define LY_TYPE_BOOL_STR "boolean" /**< text representation of ::LY_TYPE_BOOL */ |
| 34 | #define LY_TYPE_DEC64_STR "decimal64" /**< text representation of ::LY_TYPE_DEC64 */ |
| 35 | #define LY_TYPE_EMPTY_STR "empty" /**< text representation of ::LY_TYPE_EMPTY */ |
| 36 | #define LY_TYPE_ENUM_STR "enumeration" /**< text representation of ::LY_TYPE_ENUM */ |
| 37 | #define LY_TYPE_IDENT_STR "identityref" /**< text representation of ::LY_TYPE_IDENT */ |
| 38 | #define LY_TYPE_INST_STR "instance-identifier" /**< text representation of ::LY_TYPE_INST */ |
| 39 | #define LY_TYPE_LEAFREF_STR "leafref" /**< text representation of ::LY_TYPE_LEAFREF */ |
| 40 | #define LY_TYPE_UNION_STR "union" /**< text representation of ::LY_TYPE_UNION */ |
| 41 | #define LY_TYPE_INT8_STR "8bit integer" /**< text representation of ::LY_TYPE_INT8 */ |
| 42 | #define LY_TYPE_INT16_STR "16bit integer" /**< text representation of ::LY_TYPE_INT16 */ |
| 43 | #define LY_TYPE_INT32_STR "32bit integer" /**< text representation of ::LY_TYPE_INT32 */ |
| 44 | #define LY_TYPE_INT64_STR "64bit integer" /**< text representation of ::LY_TYPE_INT64 */ |
| 45 | |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 46 | /** |
| 47 | * @brief Initiate libyang plugins. |
| 48 | * |
| 49 | * Covers both the types and extensions plugins. |
| 50 | * |
Michal Vasko | 6a027db | 2024-02-21 09:55:34 +0100 | [diff] [blame] | 51 | * @param[in] builtin_type_plugins_only Whether to load only built-in YANG type plugins and no included extension plugins. |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 52 | * @return LY_SUCCESS in case of success |
| 53 | * @return LY_EINT in case of internal error |
| 54 | * @return LY_EMEM in case of memory allocation failure. |
| 55 | */ |
Michal Vasko | 6a027db | 2024-02-21 09:55:34 +0100 | [diff] [blame] | 56 | LY_ERR lyplg_init(ly_bool builtin_type_plugins_only); |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * @brief Remove (unload) all the plugins currently available. |
| 60 | */ |
| 61 | void lyplg_clean(void); |
| 62 | |
| 63 | /** |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 64 | * @brief Find a type plugin. |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 65 | * |
steweg | f7aeeae | 2024-04-02 13:15:52 +0200 | [diff] [blame] | 66 | * @param[in] ctx The optional context for which the plugin should be find. If NULL, only shared plugins will be searched |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 67 | * @param[in] module Name of the module where the type is defined. Must not be NULL, in case of plugins for |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 68 | * built-in types, the module is "". |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 69 | * @param[in] revision Revision of the module for which the plugin is implemented. NULL is not a wildcard, it matches |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 70 | * only the plugins with NULL revision specified. |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 71 | * @param[in] name Name of the type which the plugin implements. |
| 72 | * @return Found type plugin, NULL if none found. |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 73 | */ |
steweg | f7aeeae | 2024-04-02 13:15:52 +0200 | [diff] [blame] | 74 | struct lyplg_type *lyplg_type_plugin_find(const struct ly_ctx *ctx, const char *module, const char *revision, const char *name); |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * @brief Find an extension plugin. |
| 78 | * |
steweg | f7aeeae | 2024-04-02 13:15:52 +0200 | [diff] [blame] | 79 | * @param[in] ctx The optional context for which the plugin should be find. If NULL, only shared plugins will be searched |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 80 | * @param[in] module Name of the module where the extension is defined. |
| 81 | * @param[in] revision Revision of the module for which the plugin is implemented. NULL is not a wildcard, it matches |
| 82 | * only the plugins with NULL revision specified. |
| 83 | * @param[in] name Name of the extension which the plugin implements. |
| 84 | * @return Found extension record, NULL if none found. |
| 85 | */ |
steweg | f7aeeae | 2024-04-02 13:15:52 +0200 | [diff] [blame] | 86 | struct lyplg_ext_record *lyplg_ext_record_find(const struct ly_ctx *ctx, const char *module, const char *revision, const char *name); |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 87 | |
Radek Krejci | 04699f0 | 2021-03-22 21:50:29 +0100 | [diff] [blame] | 88 | #endif /* LY_PLUGINS_INTERNAL_H_ */ |