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 | * |
| 51 | * @return LY_SUCCESS in case of success |
| 52 | * @return LY_EINT in case of internal error |
| 53 | * @return LY_EMEM in case of memory allocation failure. |
| 54 | */ |
| 55 | LY_ERR lyplg_init(void); |
| 56 | |
| 57 | /** |
| 58 | * @brief Remove (unload) all the plugins currently available. |
| 59 | */ |
| 60 | void lyplg_clean(void); |
| 61 | |
| 62 | /** |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 63 | * @brief Find a type plugin. |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 64 | * |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 65 | * @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] | 66 | * built-in types, the module is "". |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 67 | * @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] | 68 | * only the plugins with NULL revision specified. |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 69 | * @param[in] name Name of the type which the plugin implements. |
| 70 | * @return Found type plugin, NULL if none found. |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 71 | */ |
Michal Vasko | c0c64ae | 2022-10-06 10:15:23 +0200 | [diff] [blame] | 72 | struct lyplg_type *lyplg_type_plugin_find(const char *module, const char *revision, const char *name); |
| 73 | |
| 74 | /** |
| 75 | * @brief Find an extension plugin. |
| 76 | * |
| 77 | * @param[in] module Name of the module where the extension is defined. |
| 78 | * @param[in] revision Revision of the module for which the plugin is implemented. NULL is not a wildcard, it matches |
| 79 | * only the plugins with NULL revision specified. |
| 80 | * @param[in] name Name of the extension which the plugin implements. |
| 81 | * @return Found extension record, NULL if none found. |
| 82 | */ |
| 83 | struct lyplg_ext_record *lyplg_ext_record_find(const char *module, const char *revision, const char *name); |
Radek Krejci | 3e6632f | 2021-03-22 22:08:21 +0100 | [diff] [blame] | 84 | |
Radek Krejci | 04699f0 | 2021-03-22 21:50:29 +0100 | [diff] [blame] | 85 | #endif /* LY_PLUGINS_INTERNAL_H_ */ |