2004-05-16 14:58:40 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-01-15 15:59:11 +00:00
|
|
|
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
|
2004-05-16 14:58:40 +00:00
|
|
|
* E-mail:
|
|
|
|
* <brain@chatspike.net>
|
|
|
|
* <Craig@chatspike.net>
|
|
|
|
*
|
|
|
|
* Written by Craig Edwards, Craig McLure, and others.
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
#ifndef __DLL_H
|
|
|
|
#define __DLL_H
|
|
|
|
|
2005-05-20 21:52:25 +00:00
|
|
|
typedef void * (initfunc) (void);
|
|
|
|
|
|
|
|
#include "inspircd_config.h"
|
2003-01-23 19:45:57 +00:00
|
|
|
|
|
|
|
class DLLManager
|
|
|
|
{
|
|
|
|
public:
|
2005-05-20 22:34:12 +00:00
|
|
|
DLLManager(char *fname);
|
2003-01-23 19:45:57 +00:00
|
|
|
virtual ~DLLManager();
|
|
|
|
|
|
|
|
|
2005-05-20 21:52:25 +00:00
|
|
|
#ifdef STATIC_LINK
|
2005-05-20 22:34:12 +00:00
|
|
|
bool GetSymbol( initfunc* &v, char *sym_name );
|
2005-05-20 21:52:25 +00:00
|
|
|
#else
|
2005-05-20 22:34:12 +00:00
|
|
|
bool GetSymbol( void **, char *sym_name );
|
2005-05-20 21:52:25 +00:00
|
|
|
#endif
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2005-05-20 22:34:12 +00:00
|
|
|
char *LastError()
|
2003-01-23 19:45:57 +00:00
|
|
|
{
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void *h;
|
2005-05-20 21:52:25 +00:00
|
|
|
char *err;
|
|
|
|
#ifdef STATIC_LINK
|
|
|
|
char staticname[1024];
|
|
|
|
#endif
|
2003-01-23 19:45:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DLLFactoryBase : public DLLManager
|
|
|
|
{
|
|
|
|
public:
|
2005-05-20 22:34:12 +00:00
|
|
|
DLLFactoryBase(char *fname, char *func_name = 0);
|
2003-01-23 19:45:57 +00:00
|
|
|
virtual ~DLLFactoryBase();
|
2005-05-20 21:52:25 +00:00
|
|
|
#ifdef STATIC_LINK
|
|
|
|
initfunc *factory_func;
|
|
|
|
#else
|
2003-01-23 19:45:57 +00:00
|
|
|
void * (*factory_func)(void);
|
2005-05-20 21:52:25 +00:00
|
|
|
#endif
|
2003-01-23 19:45:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-04-17 18:18:26 +00:00
|
|
|
template <class T> class DLLFactory : public DLLFactoryBase
|
2003-01-23 19:45:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2005-05-20 22:34:12 +00:00
|
|
|
DLLFactory(char *fname, char *func_name=0) : DLLFactoryBase(fname,func_name)
|
2003-01-23 19:45:57 +00:00
|
|
|
{
|
2004-04-17 18:18:26 +00:00
|
|
|
if (factory_func)
|
|
|
|
factory = (T*)factory_func();
|
|
|
|
else
|
|
|
|
factory = 0;
|
2003-01-23 19:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~DLLFactory()
|
|
|
|
{
|
|
|
|
delete factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
T *factory;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|