blob: 2ba54f13608eff622f142bdcb35e8da28e9c1417 [file] [log] [blame]
Radek Krejci04699f02021-03-22 21:50:29 +01001/**
2 * @file plugins_internal.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
Michal Vaskoc0c64ae2022-10-06 10:15:23 +02004 * @author Michal Vasko <mvasko@cesnet.cz>
Radek Krejci04699f02021-03-22 21:50:29 +01005 * @brief internal functions to support extension and type plugins.
6 *
Michal Vaskoc0c64ae2022-10-06 10:15:23 +02007 * Copyright (c) 2019-2022 CESNET, z.s.p.o.
Radek Krejci04699f02021-03-22 21:50:29 +01008 *
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 Krejci3e6632f2021-03-22 22:08:21 +010019#include <stdint.h>
20
21#include "plugins.h"
22#include "plugins_exts.h"
aPiecek704f8e92021-08-25 13:35:05 +020023#include "plugins_types.h"
Radek Krejci3e6632f2021-03-22 22:08:21 +010024
Radek Krejci04699f02021-03-22 21:50:29 +010025#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 Krejci3e6632f2021-03-22 22:08:21 +010046/**
47 * @brief Initiate libyang plugins.
48 *
49 * Covers both the types and extensions plugins.
50 *
Michal Vasko6a027db2024-02-21 09:55:34 +010051 * @param[in] builtin_type_plugins_only Whether to load only built-in YANG type plugins and no included extension plugins.
Radek Krejci3e6632f2021-03-22 22:08:21 +010052 * @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 Vasko6a027db2024-02-21 09:55:34 +010056LY_ERR lyplg_init(ly_bool builtin_type_plugins_only);
Radek Krejci3e6632f2021-03-22 22:08:21 +010057
58/**
59 * @brief Remove (unload) all the plugins currently available.
60 */
61void lyplg_clean(void);
62
63/**
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020064 * @brief Find a type plugin.
Radek Krejci3e6632f2021-03-22 22:08:21 +010065 *
stewegf7aeeae2024-04-02 13:15:52 +020066 * @param[in] ctx The optional context for which the plugin should be find. If NULL, only shared plugins will be searched
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020067 * @param[in] module Name of the module where the type is defined. Must not be NULL, in case of plugins for
Radek Krejci3e6632f2021-03-22 22:08:21 +010068 * built-in types, the module is "".
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020069 * @param[in] revision Revision of the module for which the plugin is implemented. NULL is not a wildcard, it matches
Radek Krejci3e6632f2021-03-22 22:08:21 +010070 * only the plugins with NULL revision specified.
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020071 * @param[in] name Name of the type which the plugin implements.
72 * @return Found type plugin, NULL if none found.
Radek Krejci3e6632f2021-03-22 22:08:21 +010073 */
stewegf7aeeae2024-04-02 13:15:52 +020074struct lyplg_type *lyplg_type_plugin_find(const struct ly_ctx *ctx, const char *module, const char *revision, const char *name);
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020075
76/**
77 * @brief Find an extension plugin.
78 *
stewegf7aeeae2024-04-02 13:15:52 +020079 * @param[in] ctx The optional context for which the plugin should be find. If NULL, only shared plugins will be searched
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020080 * @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 */
stewegf7aeeae2024-04-02 13:15:52 +020086struct lyplg_ext_record *lyplg_ext_record_find(const struct ly_ctx *ctx, const char *module, const char *revision, const char *name);
Radek Krejci3e6632f2021-03-22 22:08:21 +010087
Radek Krejci04699f02021-03-22 21:50:29 +010088#endif /* LY_PLUGINS_INTERNAL_H_ */