plugin test for the mentally unwell. I feel bad for using recursive Make.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

32 lines
683B

  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <dlfcn.h>
  4. #include "plug.h"
  5. int
  6. main (void)
  7. {
  8. int x = 0;
  9. char * libplug_fn = "libplug.so";
  10. void * libplug = NULL;
  11. while (1)
  12. {
  13. if (libplug) { dlclose(libplug); }
  14. libplug = dlopen(libplug_fn, RTLD_NOW);
  15. BIND(libplug, plug, "plug");
  16. if (!libplug)
  17. { fprintf(stderr, "ERR: Cannot load dynamic library %s: %s\n", libplug_fn, dlerror()); }
  18. else
  19. {
  20. *(void **) (&plug) = dlsym(libplug, "plug");
  21. printf("frame %d: ", x++);
  22. if (plug)
  23. { plug(); }
  24. else
  25. { fprintf(stderr, "ERR: Cannot find %s symbol in %s: %s\n", "plug", libplug_fn, dlerror()); }
  26. }
  27. sleep(2);
  28. }
  29. }