aboutsummaryrefslogtreecommitdiff
path: root/src/disp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/disp.c')
-rw-r--r--src/disp.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/disp.c b/src/disp.c
index 6710f40..27f74e4 100644
--- a/src/disp.c
+++ b/src/disp.c
@@ -24,12 +24,14 @@
#include "disp.h"
-#define dlsym_and_check(dest, name) \
- dest->name = dlsym(dest->dl_handle, #name); \
- if (!dest->name) { \
- dlclose(dest->dl_handle); \
- free(dest); \
- return NULL; \
+#define dlsym_and_check(dest, name) \
+ dest->name = dlsym(dest->dl_handle, #name); \
+ if ((!dest->name) || (dest->name == dest->dl_handle)) { \
+ char *msg = dlerror(); \
+ fprintf(stderr, "calculer: %s\n", msg); \
+ dlclose(dest->dl_handle); \
+ free(dest); \
+ return NULL; \
}
struct disp *
@@ -37,10 +39,10 @@ get_disp(char *disp_name)
{
#ifndef NDEBUG
/* displays are shared libraries */
- char so_path[16] = {0};
- strcpy(so_path, "./");
+ char so_path[64] = {0};
+ strcpy(so_path, "./src/.libs/");
strcat(so_path, disp_name);
- strcat(so_path, ".la");
+ strcat(so_path, ".so.0.0.0");
void *handle = dlopen(so_path, RTLD_LAZY);
if (!handle)
@@ -52,6 +54,7 @@ get_disp(char *disp_name)
struct disp *disp = malloc(sizeof(*disp));
disp->dl_handle = handle;
+ dlsym_and_check(disp, init);
dlsym_and_check(disp, display_calc);
dlsym_and_check(disp, read_input);
dlsym_and_check(disp, display_res);