#include <dlfcn.h>
#include <stdio.h>
	
char *check(const char*);

int
main(int argc, char *argv[])
{
	char *msg;
	if (!argv[1])
	{
		printf("Usage: %s 'modulename'\n",argv[0]);
		return 1;
	}

	msg=check(argv[1]);
	if (msg[0])
		return printf("Result: %s.\n",msg);
	else	printf("OK\n");

	return 0;
}

char *
check(file)
	const char *file;
{
	void *h=0,*f=0;
	
	printf("Checking file: '%s'\n",file);

	h=dlopen(file,RTLD_LAZY);
	if (!h)	return "Cannot dlopen";
	
	f = dlsym( h,"name" );
	if (!f) return "Cannot resolve name symbol";
		
	f = dlsym( h,"exec" );
	if (!f) return "Cannot resolve name symbol";
	
	f = dlsym( h,"type" );
	if (!f) return "Cannot resolve name symbol";
	
	dlclose(h);
	return "";
}

