Changeset 493
- Timestamp:
- 04/08/06 19:48:35 (3 years ago)
- Files:
-
- nepenthes/trunk/nepenthes-core/src/ModuleManager.cpp (modified) (6 diffs)
- nepenthes/trunk/nepenthes-core/src/Nepenthes.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nepenthes/trunk/nepenthes-core/src/ModuleManager.cpp
r460 r493 28 28 /* $Id$ */ 29 29 30 #ifdef WIN3231 32 #else33 30 #include <dlfcn.h> 34 #endif35 31 36 32 #include "ModuleManager.hpp" … … 165 161 bool ModuleManager::Exit() 166 162 { 167 /* list<Module *>::iterator it; 168 for( it = m_Modules.begin(); it != m_Modules.end(); it++ ) 169 unregisterModule(&(*it)->getModuleName()); 170 */ 171 172 while(m_Modules.size() > 0) 163 while ( m_Modules.size() > 0 ) 173 164 { 174 165 void *handle = m_Modules.front()->getDlHandle(); 175 166 m_Modules.front()->Exit(); 176 if(m_Modules.front()->getConfig() != NULL) 167 168 if ( m_Modules.front()->getConfig() != NULL ) 169 { 177 170 delete m_Modules.front()->getConfig(); 178 179 delete m_Modules.front(); 180 #ifdef WIN32 181 FreeLibrary((HINSTANCE)handle); 182 #else 171 } 172 173 delete m_Modules.front(); 183 174 dlclose(handle); 184 #endif185 175 m_Modules.pop_front(); 186 176 } … … 202 192 bool retval=true; 203 193 204 #ifdef WIN32205 HMODULE handle;206 #else207 194 void *handle; 208 #endif209 195 210 196 typedef int32_t (*module_init_proc)(int32_t, Module**, Nepenthes *); 211 197 module_init_proc module_init; 212 198 213 #ifdef WIN32 214 handle = LoadLibrary(modulepath->c_str()); 215 if ( handle == NULL ) 216 { 217 218 LPVOID lpMsgBuf; 219 FormatMessage( 220 FORMAT_MESSAGE_ALLOCATE_BUFFER | 221 FORMAT_MESSAGE_FROM_SYSTEM | 222 FORMAT_MESSAGE_IGNORE_INSERTS, 223 NULL, 224 GetLastError(), 225 0, // Default language 226 (LPTSTR) &lpMsgBuf, 227 0, 228 NULL 229 ); 230 printf("LoadLibary %s\n",(char *)lpMsgBuf); 231 logCrit("%s\n","handle == NULL "); 232 return false; 233 } 234 235 #else 236 handle = dlopen (modulepath->c_str(), RTLD_NOW); 199 handle = dlopen (modulepath->c_str(), RTLD_NOW|RTLD_LOCAL); 237 200 238 201 if ( handle == NULL ) … … 242 205 return false; 243 206 } 244 #endif 245 246 #ifdef WIN32 247 (FARPROC&) module_init = GetProcAddress(handle, "module_init"); 248 #else 207 249 208 module_init = (module_init_proc)dlsym(handle, "module_init"); 250 #endif251 209 if ( module_init == NULL ) 252 210 { 253 211 logCrit("%s\n","module_init == NULL" ); 254 255 #ifdef WIN32256 FreeLibrary((HMODULE) handle);257 #else258 212 dlclose (handle); 259 #endif260 261 213 return false; 262 214 } … … 267 219 268 220 logCrit("%s\n","module_init() != 1" ); 269 #ifdef WIN32270 271 #else272 221 dlclose (handle); 273 #endif274 222 return false; 275 223 } … … 304 252 logCrit("Loading Module %s failed, Module->Init() returned false\n", modulepath->c_str()); 305 253 delete newmodule; 306 #ifdef WIN32307 308 #else309 254 dlclose (handle); 310 #endif311 255 return false; 312 256 } nepenthes/trunk/nepenthes-core/src/Nepenthes.cpp
r454 r493 750 750 } 751 751 752 if( run == true )753 {754 doLoop();755 }else756 752 if (filecheck) 757 753 { 758 754 show_version(); 759 755 fileCheckMain(filecheckarg,argc,optind,argv); 756 } 757 if( run == true ) 758 { 759 doLoop(); 760 760 } 761 761
