
6 changed files with 113 additions and 4 deletions
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
/* appelant.c */ |
||||
|
||||
#include <stdio.h> |
||||
#include <dlfcn.h> |
||||
|
||||
void affichage(char *titre, float vals[4]); |
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
||||
int main(int argc, char *argv[]) |
||||
{ |
||||
void *handle; |
||||
float values[4]; |
||||
|
||||
void (*funcname)(const char*, const float *); |
||||
|
||||
handle = dlopen("./plugiciel.so", RTLD_LAZY); |
||||
if (!handle) { |
||||
/* fail to load the library */ |
||||
fprintf(stderr, "Error: %s\n", dlerror()); |
||||
return 1; |
||||
} |
||||
|
||||
*(void**)(&funcname) = dlsym(handle, "affichage"); |
||||
|
||||
values[0] = 13.37; values[1] = 16.64; |
||||
values[2] = 3.14159; values[3] = 0.5; |
||||
|
||||
funcname("rgb * a =", values); |
||||
|
||||
return 0; |
||||
} |
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
||||
|
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
/* plugiciel.c */ |
||||
|
||||
#include <stdio.h> |
||||
#include "plugiciel.h" |
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
||||
void affichage(char *titre, float vals[4]) |
||||
{ |
||||
printf("%s : %f %f %f\n", titre, |
||||
vals[0]*vals[3], vals[1]*vals[3], vals[2]*vals[3]); |
||||
} |
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
Loading…
Reference in new issue