X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdynamic.cpp;h=c75371a39b33cdbf73d3c1684dab430ea4a9e0fa;hb=eb28eaea35d9d109a0b7b890de9d957d562da675;hp=778a94521d6ddba60be3acb15ae91718ab94a394;hpb=1ff199172d2fd4fa8e7f29dbffd10c684e25e3a9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 778a94521..c75371a39 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -33,7 +33,7 @@ using namespace std; #include #include -extern ServerConfig* Config; +extern InspIRCd* ServerInstance; DLLManager::DLLManager(const char *fname) { @@ -64,7 +64,7 @@ DLLManager::DLLManager(const char *fname) // a little safer if the ircd is running at the time as the // shared libraries are mmap()ed and not doing this causes // segfaults. - /*FILE* x = fopen(fname,"rb"); + FILE* x = fopen(fname,"rb"); if (!x) { err = strerror(errno); @@ -73,7 +73,7 @@ DLLManager::DLLManager(const char *fname) log(DEBUG,"Opened module file %s",fname); char tmpfile_template[255]; char buffer[65536]; - snprintf(tmpfile_template, 255, "%s/inspircd_file.so.%d.XXXXXXXXXX",Config->TempDir,getpid()); + snprintf(tmpfile_template, 255, "%s/inspircd_file.so.%d.XXXXXXXXXX",ServerInstance->Config->TempDir,getpid()); int fd = mkstemp(tmpfile_template); if (fd == -1) { @@ -102,25 +102,25 @@ DLLManager::DLLManager(const char *fname) if (close(fd) == -1) err = strerror(errno); if (fclose(x) == EOF) - err = strerror(errno);*/ + err = strerror(errno); h = dlopen(fname, RTLD_NOW|RTLD_LOCAL); if (!h) { log(DEBUG,"dlerror occured!"); - err = dlerror(); + err = (char*)dlerror(); return; } - /*log(DEBUG,"Finished loading '%s': %0x",tmpfile_template, h); + log(DEBUG,"Finished loading '%s': %0x",tmpfile_template, h); // We can delete the tempfile once it's loaded, leaving just the inode. - if (!err && !Config->debugging) + if (!err && !ServerInstance->Config->debugging) { log(DEBUG,"Deleteting %s",tmpfile_template); if (unlink(tmpfile_template) == -1) err = strerror(errno); - }*/ + } #endif } @@ -165,19 +165,14 @@ bool DLLManager::GetSymbol(void** v, const char* sym_name) { log(DEBUG,"Found symbol %s", sym_name); dlerror(); // clear value - *v = dlsym(h, "init_module"); - err = dlerror(); - - log(DEBUG,"%s",err); + *v = dlsym(h, sym_name); + err = (char*)dlerror(); if (!*v || err) return false; - - log(DEBUG,"%0x %0x",dlsym(h, "init_module"), *v); } if (err) { - log(DEBUG,"Not found symbol"); return false; } else @@ -188,7 +183,7 @@ bool DLLManager::GetSymbol(void** v, const char* sym_name) #endif -DLLFactoryBase::DLLFactoryBase(const char* fname, const char* factory) : DLLManager(fname) +DLLFactoryBase::DLLFactoryBase(const char* fname, const char* symbol) : DLLManager(fname) { // try get the factory function if there is no error yet factory_func = 0; @@ -196,9 +191,9 @@ DLLFactoryBase::DLLFactoryBase(const char* fname, const char* factory) : DLLMana if (!LastError()) { #ifdef STATIC_LINK - if (!GetSymbol( factory_func, factory ? factory : "init_module" )) + if (!GetSymbol( factory_func, symbol ? symbol : "init_module")) #else - if (!GetSymbol( (void **)&factory_func, factory ? factory : "init_module" )) + if (!GetSymbol( (void **)&factory_func, symbol ? symbol : "init_module")) #endif { throw ModuleException("Missing init_module() entrypoint!");