2703
|
1 /***************************************************************** |
|
2 FlexDLL |
|
3 Alain Frisch |
|
4 |
|
5 Copyright 2007 Institut National de Recherche en Informatique et |
|
6 en Automatique. |
|
7 |
|
8 ******************************************************************/ |
|
9 |
|
10 /* An example (main program) */ |
|
11 |
|
12 #include <stdlib.h> |
|
13 #include <stdio.h> |
|
14 #include "flexdll.h" |
|
15 |
|
16 typedef void torun(); |
|
17 |
|
18 void api(char *msg){ printf("API: %s\n", msg); } |
|
19 |
|
20 int main(int argc, char **argv) |
|
21 { |
|
22 void *sym; |
|
23 void *handle; |
|
24 int i; |
|
25 torun *torun; |
|
26 |
|
27 printf("INIT\n"); fflush(stdout); |
|
28 flexdll_dump_exports(NULL); |
|
29 printf("OK\n"); fflush(stdout); |
|
30 for (i = 1; i < argc; i++) { |
|
31 printf("** Loading %s\n", argv[i]); |
|
32 handle = flexdll_dlopen(argv[i], FLEXDLL_RTLD_GLOBAL); |
|
33 if (NULL == handle) { printf("error: %s\n", flexdll_dlerror()); exit(2); } |
|
34 printf("** handle = %p\n", handle); |
|
35 flexdll_dump_exports(handle); |
|
36 flexdll_dump_relocations(handle); |
|
37 |
|
38 if (NULL == handle) { printf("error: %s\n", flexdll_dlerror()); exit(2); } |
|
39 |
|
40 torun = flexdll_dlsym(handle, "torun"); |
|
41 if (torun) torun(); |
|
42 } |
|
43 exit(0); |
|
44 } |