]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dynamic.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / dynamic.cpp
index 5d7759b4751761daefcff49ad083143db720867f..8731489c435cc5761f0a452b2ca6dbd5fedbaa90 100644 (file)
@@ -1 +1,67 @@
-/*       +------------------------------------+\r *       | Inspire Internet Relay Chat Daemon |\r *       +------------------------------------+\r *\r *  InspIRCd: (C) 2002-2007 InspIRCd Development Team\r * See: http://www.inspircd.org/wiki/index.php/Credits\r *\r * This program is free but copyrighted software; see\r *            the file COPYING for details.\r *\r * ---------------------------------------------------\r */\r\r#include "inspircd.h"\r#include "configreader.h"\r#include "dynamic.h"\r#ifndef WIN32\r#include <dlfcn.h>\r#endif\r\rDLLManager::DLLManager(InspIRCd* ServerInstance, const char *fname)\r{\r       err = NULL;\r\r   if (!strstr(fname,".so"))\r      {\r              err = "This doesn't look like a module file to me...";\r         return;\r        }\r\r     h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);\r        if (!h)\r        {\r              err = (char*)dlerror();\r                return;\r        }\r}\r\rDLLManager::~DLLManager()\r{\r       // close the library if it isn't null\r  if (h)\r         dlclose(h);\r}\r\r\r\rbool DLLManager::GetSymbol(void** v, const char* sym_name)\r{\r  // try extract a symbol from the library\r       // get any error message is there is any\r       \r       if (h)\r {\r              dlerror(); // clear value\r              *v = dlsym(h, sym_name);\r               err = (char*)dlerror();\r                if (!*v || err)\r                        return false;\r  }\r      \r       if (err)\r       {\r              return false;\r  }\r      else\r   {       \r               return true;\r   }\r}\r\rDLLFactoryBase::DLLFactoryBase(InspIRCd* Instance, const char* fname, const char* symbol) : DLLManager(Instance, fname)\r{\r // try get the factory function if there is no error yet\r       factory_func = 0;\r      \r       if (!LastError())\r      {\r              if (!GetSymbol( (void **)&factory_func, symbol ? symbol : "init_module"))\r              {\r                      throw ModuleException("Missing init_module() entrypoint!");\r            }\r      }\r}\r\rDLLFactoryBase::~DLLFactoryBase()\r{\r}\r\r
\ No newline at end of file
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  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.
+ *
+ * ---------------------------------------------------
+ */
+
+/* $Core */
+
+#include "inspircd.h"
+#include "dynamic.h"
+#ifndef WIN32
+#include <dlfcn.h>
+#endif
+
+DLLManager::DLLManager(const char *fname)
+{
+       err = NULL;
+
+       if (!strstr(fname,".so"))
+       {
+               err = "This doesn't look like a module file to me...";
+               return;
+       }
+
+       h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);
+       if (!h)
+       {
+               err = dlerror();
+               return;
+       }
+}
+
+DLLManager::~DLLManager()
+{
+       /* close the library */
+       if (h)
+               dlclose(h);
+}
+
+
+
+bool DLLManager::GetSymbol(void** v, const char* sym_name)
+{
+       /*
+        * try extract a symbol from the library
+        * get any error message is there is any
+        */
+
+       if (h)
+       {
+               dlerror(); // clear value
+               *v = dlsym(h, sym_name);
+               err = dlerror();
+               if (!*v || err)
+                       return false;
+       }
+
+       /* succeeded :) */
+       return true;
+}