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 */
48 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
57 dlerror(); // clear value
58 *v = dlsym(h, sym_name);
59 err = (char*)dlerror();
68 DLLFactoryBase::DLLFactoryBase(InspIRCd* Instance, const char* fname, const char* symbol) : DLLManager(Instance, fname)
70 /* try get the factory function if there is no error yet */
75 if (!GetSymbol( (void **)&factory_func, symbol ? symbol : "init_module"))
77 throw ModuleException("Missing init_module() entrypoint!");
82 DLLFactoryBase::~DLLFactoryBase()