File: plugin_config.h.in

package info (click to toggle)
libyang 0.16.105-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,544 kB
  • sloc: ansic: 96,743; xml: 9,300; cpp: 5,023; python: 1,637; java: 1,448; lex: 281; sh: 158; makefile: 72
file content (127 lines) | stat: -rw-r--r-- 3,335 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
 * @file plugin_config.h
 * @author Michal Vasko <mvasko@cesnet.cz>
 * @brief libyang plugin config file
 *
 * Copyright (c) 2018 CESNET, z.s.p.o.
 *
 * This source code is licensed under BSD 3-Clause License (the "License").
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://opensource.org/licenses/BSD-3-Clause
 */

#ifndef LY_PLUGIN_CONFIG_H_
#define LY_PLUGIN_CONFIG_H_

#define LYEXT_PLUGINS_DIR "@EXTENSIONS_PLUGINS_DIR_MACRO@" /**< directory with YANG extension plugins */
#define LY_USER_TYPES_PLUGINS_DIR "@USER_TYPES_PLUGINS_DIR_MACRO@" /**< directory with user YANG types plugins */

#if defined __linux__ || defined __unix__
#  define LY_PLUGIN_SUFFIX ".so"
#  define LY_PLUGIN_SUFFIX_LEN 3
#elif defined __APPLE__
#  define LY_PLUGIN_SUFFIX ".dylib"
#  define LY_PLUGIN_SUFFIX_LEN 6
#endif

#ifdef STATIC
@EXTERN_EXTENSIONS_LIST@
@EXTERN_USER_TYPE_LIST@

int lytype_size(struct lytype_plugin_list plugin[]) {
    struct lytype_plugin_list *tmp;
    int i = 0;
    while (1) {
        tmp = &plugin[i];
        if (!tmp) break;
        if (!tmp->module && !tmp->revision && !tmp->name && !tmp->store_clb && !tmp->free_clb) break;
        i++;
    }

    return i;
}

void lytype_add(struct lytype_plugin_list *type_plugins, uint16_t *type_plugins_count, struct lytype_plugin_list plugin[]) {
    struct lytype_plugin_list *tmp;
    int i = 0;
    while (1) {
        tmp = &plugin[i];
        if (!tmp) break;
        if (!tmp->module && !tmp->revision && !tmp->name && !tmp->store_clb && !tmp->free_clb) break;
        i++;
        memcpy(&type_plugins[*type_plugins_count], tmp, sizeof *tmp);
        (*type_plugins_count)++;
    }

    return;
}


int lyext_size(struct lyext_plugin_list plugin[]) {
    struct lyext_plugin_list *tmp;
    int i = 0;
    while (1) {
        tmp = &plugin[i];
        if (!tmp) break;
        if (!tmp->module && !tmp->revision && !tmp->name && !tmp->plugin) break;
        i++;
    }

    return i;
}

void lyext_add(struct lyext_plugin_list *ext_plugins, uint16_t *ext_plugins_count, struct lyext_plugin_list plugin[]) {
    struct lyext_plugin_list *tmp;
    int i = 0;
    while (1) {
        tmp = &plugin[i];
        if (!tmp) break;
        if (!tmp->module && !tmp->revision && !tmp->name && !tmp->plugin) break;
        i++;
        memcpy(&ext_plugins[*ext_plugins_count], tmp, sizeof *tmp);
        (*ext_plugins_count)++;
    }

    return;
}

struct lyext_plugin_list *static_load_lyext_plugins(uint16_t *count)
{
    struct lyext_plugin_list *plugin;
    uint16_t size = @EXTENSIONS_LIST_SIZE@;

    plugin = malloc(size * (sizeof *plugin));
    if (!plugin) {
        LOGMEM(NULL);
        return NULL;
    }

    *count = 0;
@MEMCPY_EXTENSIONS_LIST@
    return plugin;
}

struct lytype_plugin_list *static_load_lytype_plugins(uint16_t *count)
{
    struct lytype_plugin_list *plugin;
    uint16_t size = @USER_TYPE_LIST_SIZE@;

    plugin = malloc(size * (sizeof *plugin));
    if (!plugin) {
        LOGMEM(NULL);
        return NULL;
    }

    *count = 0;
@MEMCPY_USER_TYPE_LIST@
    return plugin;
}

uint16_t static_loaded_plugins_count = @STATIC_LOADED_PLUGINS_COUNT@;
char *static_loaded_plugins[] = {@STATIC_LOADED_PLUGINS@};

#endif /* STATIC */

#endif /* LY_PLUGIN_CONFIG_H_ */