ErrorCode ComponentManager::LoadLibrary( const char *name ) { TRACE_BEGIN( LOG_LVL_INFO ); IModule *mod = NULL; ErrorCode result = kNoError; LOG_NOTICE( "Opening Library: %s", name ); ErrorCode (*LoadLibrary)( IComponentManager *mgr ); IModule *(*GetModule)(); void *handle = dlopen( name, RTLD_LAZY ); if ( handle == NULL ) { result = kLoadFailed; LOG_WARN( "Failed to open shared lib \"%s\": %s", name, dlerror() ); } else { LoadLibrary = (ErrorCode (*)(IComponentManager *mgr))dlsym( handle, "JHCOM_LibraryEntry" ); GetModule = (IModule *(*)())dlsym( handle, "JHCOM_GetModule" ); if ( GetModule == NULL || LoadLibrary == NULL ) { result = kLoadFailed; LOG_WARN( "Failed to get symbol" ); } else { LOG( "LoadLibrary is %p", LoadLibrary ); LOG( "RegisterServices is %p", GetModule ); result = LoadLibrary( this ); if ( result == kNoError ) { mod = GetModule(); mod->AddRef(); mod->loadComponents(); ModuleInfo *info = jh_new ModuleInfo( name, mod, handle ); mModules.push_back( info ); } } } return result; }