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 * ---------------------------------------------------
20 DLLManager::DLLManager(InspIRCd* ServerInstance, const char *fname)
24 if (!strstr(fname,".so"))
26 err = "This doesn't look like a module file to me...";
30 h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);
33 err = (char*)dlerror();
38 DLLManager::~DLLManager()
40 /* close the library */
47 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
56 dlerror(); // clear value
57 *v = dlsym(h, sym_name);
58 err = (char*)dlerror();
67 DLLFactoryBase::DLLFactoryBase(InspIRCd* Instance, const char* fname, const char* symbol) : DLLManager(Instance, fname)
69 /* try get the factory function if there is no error yet */
74 if (!GetSymbol( (void **)&factory_func, symbol ? symbol : "init_module"))
76 throw ModuleException("Missing init_module() entrypoint!");
81 DLLFactoryBase::~DLLFactoryBase()