blob: 59adacfd70f3b46010eb2e55cd4cc153852f997b [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 *
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020066 * @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 +010067 * built-in types, the module is "".
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020068 * @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 +010069 * only the plugins with NULL revision specified.
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020070 * @param[in] name Name of the type which the plugin implements.
71 * @return Found type plugin, NULL if none found.
Radek Krejci3e6632f2021-03-22 22:08:21 +010072 */
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020073struct lyplg_type *lyplg_type_plugin_find(const char *module, const char *revision, const char *name);
74
75/**
76 * @brief Find an extension plugin.
77 *
78 * @param[in] module Name of the module where the extension is defined.
79 * @param[in] revision Revision of the module for which the plugin is implemented. NULL is not a wildcard, it matches
80 * only the plugins with NULL revision specified.
81 * @param[in] name Name of the extension which the plugin implements.
82 * @return Found extension record, NULL if none found.
83 */
84struct lyplg_ext_record *lyplg_ext_record_find(const char *module, const char *revision, const char *name);
Radek Krejci3e6632f2021-03-22 22:08:21 +010085
Radek Krejci04699f02021-03-22 21:50:29 +010086#endif /* LY_PLUGINS_INTERNAL_H_ */