12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #ifdef HAVE_CONFIG_H
- # include <config.h>
- #endif
- #include <dlfcn.h>
- #include <stdio.h>
- #include <limits.h>
- #include <sys/stat.h>
- int main(int argc, char **argv)
- {
- int i;
- struct stat st;
- char buf[PATH_MAX];
- for (i = 1; i < argc; i++) {
- if (dlopen(argv[i], RTLD_NOW)) {
- fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
- argv[i]);
- } else {
- snprintf(buf, sizeof(buf), "./%s", argv[i]);
- if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
- fprintf(stdout, "dlopen() of \"./%s\" "
- "succeeded.\n", argv[i]);
- } else {
- fprintf(stdout, "dlopen() of \"%s\" failed: "
- "%s\n", argv[i], dlerror());
- return 1;
- }
- }
- }
- return 0;
- }
|