-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.h
57 lines (45 loc) · 1.4 KB
/
plugin.h
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
#pragma once
#include "config.h"
#include "config-verify.h"
#include "module.h"
#include "particle.h"
typedef bool (*verify_func_t)(keychain_t *chain, const struct yml_node *node);
struct module_iface {
verify_func_t verify_conf;
struct module *(*from_conf)(
const struct yml_node *node, struct conf_inherit inherited);
};
struct particle_iface {
verify_func_t verify_conf;
struct particle *(*from_conf)(
const struct yml_node *node, struct particle *common);
};
struct deco_iface {
verify_func_t verify_conf;
struct deco *(*from_conf)(const struct yml_node *node);
};
const struct module_iface *plugin_load_module(const char *name);
const struct particle_iface *plugin_load_particle(const char *name);
const struct deco_iface *plugin_load_deco(const char *name);
enum plugin_type { PLUGIN_MODULE, PLUGIN_PARTICLE, PLUGIN_DECORATION };
struct plugin {
char *name;
enum plugin_type type;
void *lib;
union {
const struct module_iface *module;
const struct particle_iface *particle;
const struct deco_iface *decoration;
const void *dummy;
#if 0
struct {
void *sym1;
void *sym2;
} dummy;
struct module_iface module;
struct particle_iface particle;
struct deco_iface decoration;
#endif
};
};
const struct plugin *plugin_load(const char *name, enum plugin_type type);