]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_opersha256.cpp
Wahhhhhhhhhhhh bwahahaha. Mass commit to tidy up tons of messy include lists
[user/henk/code/inspircd.git] / src / modules / m_opersha256.cpp
index f7cb6afcabb44ba840d697744f416ca80e4fa3d0..92579cdaf875fbe24339b42be8f85fdf75df02a6 100644 (file)
 using namespace std;
 
 #include <stdio.h>
-#include "inttypes.h"
+#include "inspircd_config.h"
+#ifdef HAS_STDINT
+#include <stdint.h>
+#endif
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "helperfuncs.h"
 
-Server *Srv;
+#include "inspircd.h"
+
+
 
 #define SHA256_DIGEST_SIZE (256 / 8)
 #define SHA256_BLOCK_SIZE  (512 / 8)
 
-struct SHA256Context
+#ifndef HAS_STDINT
+typedef unsigned int uint32_t;
+#endif
+
+class SHA256Context : public classbase
 {
+ public:
        unsigned int tot_len;
        unsigned int len;
        unsigned char block[2 * SHA256_BLOCK_SIZE];
@@ -219,16 +228,17 @@ void SHA256(const char *src, char *dest, int len)
 class cmd_mksha256 : public command_t
 {
 public:
      cmd_mksha256() : command_t("MKSHA256", 'o', 1)
cmd_mksha256 (InspIRCd* Instance) : command_t(Instance,"MKSHA256", 'o', 1)
        {
                this->source = "m_opersha256.so";
+               syntax = "<any-text>";
        }
 
-       void Handle(char **parameters, int pcnt, userrec *user)
+       void Handle(const char** parameters, int pcnt, userrec *user)
        {
                char buffer[SHA256_BLOCK_SIZE + 1];
                SHA256(parameters[0], buffer, strlen(parameters[0]));
-               WriteServ(user->fd, "NOTICE %s :SHA256 hashed password for %s is %s", user->nick, parameters[0], buffer);
+               user->WriteServ( "NOTICE %s :SHA256 hashed password for %s is %s", user->nick, parameters[0], buffer);
        }
 };
 
@@ -237,11 +247,11 @@ class ModuleOperSHA256 : public Module
        cmd_mksha256 *mksha256cmd;
 public:
 
-       ModuleOperSHA256(Server *Me) : Module::Module(Me)
+       ModuleOperSHA256(InspIRCd* Me) : Module::Module(Me)
        {
-               Srv = Me;
-               mksha256cmd = new cmd_mksha256();
-               Srv->AddCommand(mksha256cmd);
+               
+               mksha256cmd = new cmd_mksha256(ServerInstance);
+               ServerInstance->AddCommand(mksha256cmd);
        }
 
        virtual ~ModuleOperSHA256()
@@ -253,7 +263,7 @@ public:
                List[I_OnOperCompare] = 1;
        }
 
-       virtual int OnOperCompare(std::string data, std::string input)
+       virtual int OnOperCompare(const std::string &data, const std::string &input)
        {
                if (data.length() == SHA256_BLOCK_SIZE) // If the data is as long as a hex sha256 hash, try it as that
                {
@@ -285,7 +295,7 @@ public:
        {
        }
 
-       virtual Module *CreateModule(Server* Me)
+       virtual Module *CreateModule(InspIRCd* Me)
        {
                return new ModuleOperSHA256(Me);
        }