summaryrefslogtreecommitdiff
path: root/Documentation/maintainers/try_dlopen.c
blob: 7ff695810b98a3ff37fb688e9331a12b57ce959d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <dlfcn.h>

/**
 * Attempts to load shared libraries
 * @param argc
 * @param argv files to check (pass only shared libs)
 * @return 0 - all shared libs loaded, 1 - error occured (invalid or broken files passed)
 */
int main(int argc, char* argv[])
{
	int i;
	for (i = 1; i < argc; ++i) {
		void* handle = dlopen(argv[i], RTLD_NOW);
		if (!handle) {
			fprintf(stderr, "%s\n", dlerror());
			return 1;
		} else {
			dlclose(handle);
		}
	}
	return 0;
}