]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/dynamic.h
Move all local-only fields to LocalUser
[user/henk/code/inspircd.git] / include / dynamic.h
index 4440c476de1843dc64285b8cc71065d194b61b70..12f6ffbc9a2de6d47927665684f3ecee97c8a24f 100644 (file)
@@ -2,85 +2,53 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                       E-mail:
- *                <brain@chatspike.net>
- *               <Craig@chatspike.net>
- *     
- * Written by Craig Edwards, Craig McLure, and others.
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
  *
  * ---------------------------------------------------
  */
 
-
 #ifndef __DLL_H
 #define __DLL_H
 
-typedef void * (initfunc) (void);
-
-#include "inspircd_config.h"
-
-class InspIRCd;
+class Module;
 
-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
 {
+ protected:
+       /** The last error string
+        */
+       std::string err;
+
  public:
-       DLLManager(InspIRCd* ServerInstance, const char *fname);
+       /** 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();
 
-
-#ifdef STATIC_LINK
-       bool GetSymbol( initfunc* &v, const char *sym_name );
-#else
-       bool GetSymbol( void **, const char *sym_name );
-#endif
-
-       char* LastError() 
+       /** Get the last error from dlopen() or dlsym().
+        */
+       const std::string& LastError()
        {
                 return err;
        }
-       
- protected:
-       void *h;
-       char *err;
-#ifdef STATIC_LINK
-       char staticname[1024];
-#endif
-};
 
+       /** The module library handle.
+        */
+       void *h;
 
-class DLLFactoryBase : public DLLManager
-{
- public:
-       DLLFactoryBase(InspIRCd* Instance, const char *fname, const char *func_name = 0);
-       virtual ~DLLFactoryBase();
-#ifdef STATIC_LINK
-       initfunc *factory_func;
-#else
-       void * (*factory_func)(void);   
-#endif
-};
-
-template <class T> class DLLFactory : public DLLFactoryBase
-{
- public:
-       DLLFactory(InspIRCd* Instance, const char *fname, const char *func_name=0) : DLLFactoryBase(Instance, fname, func_name)
-       {
-               if (factory_func)
-                       factory = reinterpret_cast<T*>(factory_func());
-               else
-                       factory = reinterpret_cast<T*>(-1);
-       }
-       
-       ~DLLFactory()
-       {
-               if (factory)
-                       delete factory;
-       }
-
-       T *factory;
+       /** Return a module by calling the init function
+        */
+       Module* callInit();
 };
 
 #endif
+