]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/dynamic.h
Use SQUERY instead of PRIVMSG in alias/passforward config.
[user/henk/code/inspircd.git] / include / dynamic.h
index 276b21f135db03f14a2207bf9034335963751c1e..c14452f8c1f42a7401ee48cace9e29695f69d476 100644 (file)
@@ -1,89 +1,70 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
- *                       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.
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2007, 2009 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2007 Oliver Lupton <oliverlupton@gmail.com>
+ *   Copyright (C) 2003-2004, 2007 Craig Edwards <craigedwards@brainbox.cc>
  *
- * ---------------------------------------------------
+ * 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 <http://www.gnu.org/licenses/>.
  */
 
 
-#ifndef __DLL_H
-#define __DLL_H
+#pragma once
 
-typedef void * (initfunc) (void);
+/** 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;
 
-#include "inspircd_config.h"
+       /** Sets the last error string
+       */
+       void RetrieveLastError();
 
-class DLLManager
-{
  public:
-       DLLManager(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, char *sym_name );
-#else
-       bool GetSymbol( void **, 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(char *fname, char *func_name = 0);
-       virtual ~DLLFactoryBase();
-#ifdef STATIC_LINK
-       initfunc *factory_func;
-#else
-       void * (*factory_func)(void);   
-#endif
-};
-
+       /** Return a module by calling the init function
+        */
+       Module* CallInit();
 
-template <class T> 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()
-       {
-               delete factory;
-       }
+       /** Retrieves the value of the specified symbol.
+        * @param name The name of the symbol to retrieve.
+        * @return Either the value of the specified symbol or or NULL if it does not exist.
+        */
+       void* GetSymbol(const char* name);
 
-       T *factory;
+       /** Get detailed version information from the module file */
+       std::string GetVersion();
 };
-
-
-
-
-
-
-#endif