1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
15 #include "configreader.h"
21 DLLManager::DLLManager(InspIRCd* ServerInstance, const char *fname)
25 if (!strstr(fname,".so"))
27 err = "This doesn't look like a module file to me...";
31 h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);
34 err = (char*)dlerror();
39 DLLManager::~DLLManager()
41 // close the library if it isn't null
48 bool DLLManager::GetSymbol(void** v, const char* sym_name)
50 // try extract a symbol from the library
51 // get any error message is there is any
55 dlerror(); // clear value
56 *v = dlsym(h, sym_name);
57 err = (char*)dlerror();
72 DLLFactoryBase::DLLFactoryBase(InspIRCd* Instance, const char* fname, const char* symbol) : DLLManager(Instance, fname)
74 // try get the factory function if there is no error yet
79 if (!GetSymbol( (void **)&factory_func, symbol ? symbol : "init_module"))
81 throw ModuleException("Missing init_module() entrypoint!");
86 DLLFactoryBase::~DLLFactoryBase()