|
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.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)
- {
- libplug = dlopen(libplug_fn, RTLD_NOW);
- if (!libplug)
- { fprintf(stderr, "ERR: Cannot load dynamic library %s: %s\n", libplug_fn, dlerror()); }
- else
- {
- PLUGIN(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()); }
- dlclose(libplug);
- }
- sleep(2);
- }
- }
|