|
|
@@ -0,0 +1,31 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <unistd.h> |
|
|
|
#include <dlfcn.h> |
|
|
|
|
|
|
|
#include "plug.h" |
|
|
|
|
|
|
|
int |
|
|
|
main (void) |
|
|
|
{ |
|
|
|
int x = 0; |
|
|
|
char * libplug_fn = "libplug.so"; |
|
|
|
void * libplug = NULL; |
|
|
|
while (1) |
|
|
|
{ |
|
|
|
if (libplug) { dlclose(libplug); } |
|
|
|
libplug = dlopen(libplug_fn, RTLD_NOW); |
|
|
|
BIND(libplug, plug, "plug"); |
|
|
|
if (!libplug) |
|
|
|
{ fprintf(stderr, "ERR: Cannot load dynamic library %s: %s\n", libplug_fn, dlerror()); } |
|
|
|
else |
|
|
|
{ |
|
|
|
*(void **) (&plug) = dlsym(libplug, "plug"); |
|
|
|
printf("frame %d: ", x++); |
|
|
|
if (plug) |
|
|
|
{ plug(); } |
|
|
|
else |
|
|
|
{ fprintf(stderr, "ERR: Cannot find %s symbol in %s: %s\n", "plug", libplug_fn, dlerror()); } |
|
|
|
} |
|
|
|
sleep(2); |
|
|
|
} |
|
|
|
} |