]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sha256.cpp
To be more specific, specify rpath() macro here
[user/henk/code/inspircd.git] / src / modules / m_sha256.cpp
index f446633b63c7844d94b013bf8806c9a230ec80fa..6ba625a412673444f729c7ab90fff99e0a912610 100644 (file)
@@ -2,12 +2,9 @@
  *       | 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-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
  *
@@ -51,7 +48,7 @@
  */
 
 /* $ModDesc: Allows for SHA-256 encrypted oper passwords */
-/* $ModDep: m_sha256.h */
+/* $ModDep: m_hash.h */
 
 #include "inspircd_config.h"
 #ifdef HAS_STDINT
@@ -62,7 +59,7 @@
 #include "modules.h"
 #include "inspircd.h"
 
-#include "m_sha256.h"
+#include "m_hash.h"
 
 #ifndef HAS_STDINT
 typedef unsigned int uint32_t;
@@ -249,10 +246,12 @@ class ModuleSHA256 : public Module
 
        ModuleSHA256(InspIRCd* Me) : Module::Module(Me), key(NULL), chars(NULL)
        {
+               ServerInstance->PublishInterface("HashRequest", this);
        }
 
        virtual ~ModuleSHA256()
        {
+               ServerInstance->UnpublishInterface("HashRequest", this);
        }
 
        void Implements(char *List)
@@ -262,22 +261,26 @@ class ModuleSHA256 : public Module
 
        virtual char* OnRequest(Request* request)
        {
-               SHA256Request* SHA = (SHA256Request*)request;
-               if (strcmp("SHA256_KEY", request->GetId()) == 0)
+               HashRequest* SHA = (HashRequest*)request;
+               if (strcmp("KEY", request->GetId()) == 0)
                {
                        this->key = (unsigned int*)SHA->GetKeyData();
                }
-               else if (strcmp("SHA256_HEX", request->GetId()) == 0)
+               else if (strcmp("HEX", request->GetId()) == 0)
                {
                        this->chars = (char*)SHA->GetOutputs();
                }
-               else if (strcmp("SHA256_SUM", request->GetId()) == 0)
+               else if (strcmp("SUM", request->GetId()) == 0)
                {
                        static char data[MAXBUF];
                        SHA256((const char*)SHA->GetHashData(), data, strlen(SHA->GetHashData()), chars ? chars : "0123456789abcdef", key);
                        return data;
                }
-               else if (strcmp("SHA256_RESET", request->GetId()) == 0)
+               else if (strcmp("NAME", request->GetId()) == 0)
+               {
+                       return "sha256";
+               }
+               else if (strcmp("RESET", request->GetId()) == 0)
                {
                        this->chars = NULL;
                        this->key = NULL;
@@ -287,7 +290,7 @@ class ModuleSHA256 : public Module
 
        virtual Version GetVersion()
        {
-               return Version(1, 1, 0, 1, VF_VENDOR, API_VERSION);
+               return Version(1, 1, 0, 1, VF_VENDOR|VF_SERVICEPROVIDER, API_VERSION);
        }
 };