aboutsummaryrefslogtreecommitdiffstats
path: root/v3/libglouglou/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'v3/libglouglou/utils.c')
-rw-r--r--v3/libglouglou/utils.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/v3/libglouglou/utils.c b/v3/libglouglou/utils.c
index a3581c2..60601e1 100644
--- a/v3/libglouglou/utils.c
+++ b/v3/libglouglou/utils.c
@@ -107,15 +107,16 @@ droppriv(char *user, int do_chroot, char *chroot_path)
endpwent();
}
-/* Loads modules from path and returns a list of handles */
+/* Loads modules from path and returns a list of handles
+ * If cb_dlsym() is not null, it is called for every module */
struct modules *
-modules_load(char *path, char *check_sym) {
+modules_load(char *path, void *(cb_dlsym)(void *)) {
struct modules *modules;
struct mod *mod;
DIR *d;
struct dirent *ent;
- int n;
- void *handle, *sym;
+ int n, sym_ok, modid;
+ void *handle, *dl;
modules = xcalloc(1, sizeof(struct modules));
@@ -130,14 +131,12 @@ modules_load(char *path, char *check_sym) {
if (!handle)
continue;
dlerror(); // clear errors
- if (check_sym) {
- sym = dlsym(handle, check_sym);
- if (!sym)
- continue;
- dlerror(); // clear errors
- }
+ if (cb_dlsym)
+ dl = cb_dlsym(handle);
mod = xcalloc(1, sizeof(struct mod));
mod->handle = handle;
+ mod->name = strdup(ent->d_name);
+ mod->dl = dl;
LIST_INSERT_HEAD(&modules->list, mod, entry);
modules->count++;
}