From 45c86417cbac76159918e1429a391e2eb510bc32 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 30 Jan 2007 22:36:18 +0000 Subject: Added some more helpers to Plugger, which really needs to get with the times and use Hash and exceptions. --- src/plugger.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugger.h b/src/plugger.h index 4faca92..b531fae 100644 --- a/src/plugger.h +++ b/src/plugger.h @@ -115,7 +115,17 @@ public: void registerExternalPlugin( const char *sFName, const char *sPluginName ) { - PluginReg *pReg = new PluginReg; + PluginReg *pReg = (PluginReg *)hPlugin[sPluginName]; + if( pReg != NULL ) + { + hPlugin.del( sPluginName ); + dlclose( pReg->dlHandle ); + delete pReg; + pReg = NULL; + } + + pReg = new PluginReg; + pReg->bBuiltin = false; pReg->dlHandle = dlopen( sFName, RTLD_NOW ); if( pReg->dlHandle == NULL ) @@ -165,6 +175,20 @@ public: hObj.del( pPlug ); } + void unloadAll() + { + std::list::iterator i; + for( i = lPlugin.begin(); i != lPlugin.end(); i++ ) + { + if( (*i)->bBuiltin == false ) + { + dlclose( (*i)->dlHandle ); + } + delete (*i); + } + hPlugin.clear(); + } + private: std::list lPlugin; HashTable hPlugin; -- cgit v1.2.3