blob: d13db16475ff4f59aca201b0e7230cc720f677d0 [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 *
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 */
55LY_ERR lyplg_init(void);
56
57/**
58 * @brief Remove (unload) all the plugins currently available.
59 */
60void lyplg_clean(void);
61
62/**
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020063 * @brief Find a type plugin.
Radek Krejci3e6632f2021-03-22 22:08:21 +010064 *
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020065 * @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 +010066 * built-in types, the module is "".
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020067 * @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 +010068 * only the plugins with NULL revision specified.
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020069 * @param[in] name Name of the type which the plugin implements.
70 * @return Found type plugin, NULL if none found.
Radek Krejci3e6632f2021-03-22 22:08:21 +010071 */
Michal Vaskoc0c64ae2022-10-06 10:15:23 +020072struct 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 */
83struct lyplg_ext_record *lyplg_ext_record_find(const char *module, const char *revision, const char *name);
Radek Krejci3e6632f2021-03-22 22:08:21 +010084
Radek Krejci04699f02021-03-22 21:50:29 +010085#endif /* LY_PLUGINS_INTERNAL_H_ */