Skip to content
Extraits de code Groupes Projets

Modules

Fusionnées Kubat a demandé de fusionner dev-kubat vers master
Affichage du commit 99593911
Suivant
Afficher la dernière version
4 fichiers
+ 23
3
Comparer les modifications
  • Côte à côte
  • En ligne
Fichiers
4
+ 15
3
#pragma once
#if ! defined(__REG_H__)
struct lkt_state;
@@ -9,18 +9,28 @@ struct module_reg {
void (*func)(void);
};
extern struct module_reg *reg;
#define REG_BEGIN(reg) struct module_reg reg[] = {
#define REG_ADD(__f) { .name = #__f, .func = (void(*)(void)) __f },
#define REG_ADD_NAMED(__n, __f) { .name = __n, .func = (void(*)(void)) __f },
#define REG_END() { .name = NULL, .func = NULL } };
#if ! defined(_STATIC_MODULES)
#define REG_EXPORT(__reg) struct module_reg *__reg__ = __reg;
#else
#define REG_EXPORT(__reg)
#endif
/* If handle is NULL, file is unused and the reg is red. Otherwise,
we use dlfcn to search for the symbol which is returned. If *handle
is NULL, it will be created by opening the file. */
void *reg_pick(const char *file, void **handle, const char *symbol);
/* Get the reg from a .so file. This reg must be exported by the
shared library with REG_EXPORT. Note that this reg is named `__reg__`,
thus no symbol must be named `__reg__` in the .so file.
Returns 0 on success, something else on error. */
int reg_from_file(const char *file, struct module_reg *ret);
/* Set the ref for this .a / .so file */
void reg_set(struct module_reg *);
@@ -28,3 +38,5 @@ void reg_set(struct module_reg *);
type is done, it is up to the user to check if the structure passed as a
`void*` is the right structure. */
int load_module_by_name(struct lkt_state *srv, const char *name, void *mod);
#endif
Chargement en cours