updated on Thu Jan 19 16:10:29 UTC 2012
[aur-mirror.git] / eggdrop / dlopen.c
blob0a96da8ae24b515b5109fb004b47e837df925b2b
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <limits.h>
4 #include <sys/stat.h>
5 /* Simple program to see if dlopen() would succeed. */
6 int main(int argc, char **argv)
8 int i;
9 struct stat st;
10 char buf[PATH_MAX];
11 for (i = 1; i < argc; i++) {
12 if (dlopen(argv[i], RTLD_NOW)) {
13 fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
14 argv[i]);
15 } else {
16 snprintf(buf, sizeof(buf), "./%s", argv[i]);
17 if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
18 fprintf(stdout, "dlopen() of \"./%s\" "
19 "succeeded.\n", argv[i]);
20 } else {
21 fprintf(stdout, "dlopen() of \"%s\" failed: "
22 "%s\n", argv[i], dlerror());
23 return 1;
27 return 0;