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 * ---------------------------------------------------
14 #include "configreader.h"
22 DLLManager::DLLManager(InspIRCd* ServerInstance, const char *fname)
26 if (!strstr(fname,".so"))
28 err = "This doesn't look like a module file to me...";
32 h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);
35 err = (char*)dlerror();
40 DLLManager::~DLLManager()
42 // close the library if it isn't null
49 bool DLLManager::GetSymbol(void** v, const char* sym_name)
51 // try extract a symbol from the library
52 // get any error message is there is any
56 dlerror(); // clear value
57 *v = dlsym(h, sym_name);
58 err = (char*)dlerror();
73 DLLFactoryBase::DLLFactoryBase(InspIRCd* Instance, const char* fname, const char* symbol) : DLLManager(Instance, fname)
75 // try get the factory function if there is no error yet
80 if (!GetSymbol( (void **)&factory_func, symbol ? symbol : "init_module"))
82 throw ModuleException("Missing init_module() entrypoint!");
87 DLLFactoryBase::~DLLFactoryBase()