1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
19 #include "inspircd_config.h"
29 #include "inspstring.h"
30 #include "helperfuncs.h"
32 DLLManager::DLLManager(char *fname)
35 this->staticname[0] = '\0';
36 log(DEBUG,"Loading core-compiled module '%s'",fname);
37 for (int j = 0; modsyms[j].name; j++)
39 log(DEBUG,"Check %s",modsyms[j].name);
40 if (!strcmp(modsyms[j].name,fname))
42 log(DEBUG,"Found %s",fname);
43 strlcpy(this->staticname,fname,1020);
48 err = "Module is not statically compiled into the ircd";
50 // Try to open the library now and get any error message.
52 h = dlopen( fname, RTLD_NOW );
53 err = (char*)dlerror();
57 DLLManager::~DLLManager()
60 // close the library if it isn't null
70 bool DLLManager::GetSymbol(initfunc* &v, char *sym_name)
72 log(DEBUG,"Symbol search...");
73 for (int j = 0; modsyms[j].name; j++)
75 if (!strcmp(this->staticname,modsyms[j].name))
77 log(DEBUG,"Loading symbol...");
83 err = "Module symbol missing from the core";
89 bool DLLManager::GetSymbol(void **v, char *sym_name)
91 // try extract a symbol from the library
92 // get any error message is there is any
96 *v = dlsym( h, sym_name );
97 err = (char*)dlerror();
111 DLLFactoryBase::DLLFactoryBase(char *fname, char *factory) : DLLManager(fname)
113 // try get the factory function if there is no error yet
120 GetSymbol( factory_func, factory ? factory : (char*)"init_module" );
122 GetSymbol( (void **)&factory_func, factory ? factory : (char*)"init_module" );
128 DLLFactoryBase::~DLLFactoryBase()