1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
void Model::LoadControllerModule( const char *lib )
{
printf( "[Ctrl \"%s\"]\n", lib );
// Initialise libltdl.
int errors = lt_dlinit();
if (errors)
{
printf( "Libtool error: %s. Failed to init libtool. Quitting\n",
lt_dlerror() ); // report the error from libtool
puts( "libtool error #1" );
fflush( stdout );
exit(-1);
}
printf( "[STAGEPATH: %s]\n", FileManager::stagePath().c_str());
lt_dlsetsearchpath( FileManager::stagePath().c_str() );
printf( "ltdl search path: %s\n", lt_dlgetsearchpath() );
// PLUGIN_PATH now defined in config.h
lt_dladdsearchdir( PLUGIN_PATH );
printf( "ltdl search path: %s\n", lt_dlgetsearchpath() );
lt_dlhandle handle = NULL;
// the library name is the first word in the string
char libname[256];
sscanf( lib, "%s %*s", libname );
printf( "libname: %s\n", libname );
if(( handle = lt_dlopenext( libname ) ))
{
model_callback_t initfunc = (model_callback_t)lt_dlsym( handle,
"Init" );
if( initfunc == NULL )
{
printf( "(Libtool error: %s.) Something is wrong with your
plugin.\n",
lt_dlerror() ); // report the error from libtool
puts( "libtool error #1" );
fflush( stdout );
exit(-1);
}
// pass complete string into initfunc
AddCallback( CB_INIT, initfunc, new CtrlArgs(lib, World::ctrlargs)
);
}
else
{
printf( "(Libtool error: %s.) Can't open your plugin.\n",
lt_dlerror() ); // report the error from libtool
PRINT_ERR1( "Failed to open \"%s\". Check that it can be found by
searching the directories"
"in your STAGEPATH environment variable, or the current
directory if STAGEPATH "
"is not set.]\n", libname );
printf( "ctrl \"%s\" STAGEPATH \"%s\"\n", libname, PLUGIN_PATH );
puts( "libtool error #2" );
fflush( stdout );
exit(-1);
}
fflush(stdout);
}
|