X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fdynamic.h;h=5e66ddbb0493938a440eb42afcabf1f3c0447833;hb=e6601069038c35c546fd3f3dce95024b0d13f1b4;hp=ee43d1712cd99b52cec8258a6296dae484be1928;hpb=6fa35bdb1814ef4eab42d050e283d05910dbf3d2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/dynamic.h b/include/dynamic.h index ee43d1712..5e66ddbb0 100644 --- a/include/dynamic.h +++ b/include/dynamic.h @@ -1,89 +1,70 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * - * - * - * Written by Craig Edwards, Craig McLure, and others. - * This program is free but copyrighted software; see - * the file COPYING for details. + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2007, 2009 Dennis Friis + * Copyright (C) 2007 Oliver Lupton + * Copyright (C) 2003-2004, 2007 Craig Edwards * - * --------------------------------------------------- + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#ifndef __DLL_H -#define __DLL_H - -typedef void * (initfunc) (void); +#ifndef DLL_H +#define DLL_H -#include "inspircd_config.h" - -class DLLManager +/** The DLLManager class is able to load a module file by filename, + * and locate its init_module symbol. + */ +class CoreExport DLLManager : public classbase { - public: - DLLManager(char *fname); - virtual ~DLLManager(); - - -#ifdef STATIC_LINK - bool GetSymbol( initfunc* &v, char *sym_name ); -#else - bool GetSymbol( void **, char *sym_name ); -#endif - - char* LastError() - { - return err; - } - protected: - void *h; - char *err; -#ifdef STATIC_LINK - char staticname[1024]; + /** The last error string + */ + std::string err; + +#ifdef _WIN32 + /** Sets the last error string + */ + void RetrieveLastError(); #endif -}; - -class DLLFactoryBase : public DLLManager -{ public: - DLLFactoryBase(char *fname, char *func_name = 0); - virtual ~DLLFactoryBase(); -#ifdef STATIC_LINK - initfunc *factory_func; -#else - void * (*factory_func)(void); -#endif -}; - + /** This constructor loads the module using dlopen() + * @param fname The filename to load. This should be within + * the modules dir. + */ + DLLManager(const char *fname); + virtual ~DLLManager(); -template class DLLFactory : public DLLFactoryBase -{ - public: - DLLFactory(char *fname, char *func_name=0) : DLLFactoryBase(fname,func_name) - { - if (factory_func) - factory = (T*)factory_func(); - else - factory = 0; - } - - ~DLLFactory() + /** Get the last error from dlopen() or dlsym(). + */ + const std::string& LastError() { - delete factory; + return err; } - T *factory; -}; - - - + /** The module library handle. + */ + void *h; + /** Return a module by calling the init function + */ + Module* CallInit(); + /** Get detailed version information from the module file */ + std::string GetVersion(); +}; #endif +