Revision 238 (by dpavlin, 2004/03/08 17:46:16) tagging openisis 0.9.0
/*
	openisis - an open implementation of the CDS/ISIS database
	Version 0.8.x (patchlevel see file Version)
	Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

	see README for more information
EOH */

/*
	$Id: oipl.c,v 1.2 2003/04/08 00:20:53 kripke Exp $
	OpenIsis page loader
*/

#include <dlfcn.h> /* dlopen et al. */
#include <stdio.h>



int main ( int argc, const char **argv )
{
	int (*m)( int, const char ** );
	const char *err = 0;
	const char *dlfile = argv[1];
	void *dl = dlopen( dlfile, RTLD_LAZY );
	int ret;
	if ( ! dl ) {
		fprintf( stderr, "could not open dlfile '%s': %s\n",
			dlfile, (err = dlerror()) ? err : "?" );
		return 1;
	}
	m = dlsym( dl, "main" );
	if ( ! m ) {
		fprintf( stderr, "could not link main in '%s': %s\n",
			dlfile, (err = dlerror()) ? err : "?" );
		return 2;
	}
	ret = m( --argc, ++argv );
	dlclose( dl );
	return ret;
}