]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sethost.cpp
A few more I missed.
[user/henk/code/inspircd.git] / src / modules / m_sethost.cpp
index 048756b6d20290261f2c6aaa1c602667432e1c50..e69a944e745dc3b279da4622f17739ae0f7d084b 100644 (file)
  * ---------------------------------------------------
  */
 
-#include <stdio.h>
-#include <string>
+#include "inspircd.h"
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
 
-#include "inspircd.h"
-
 /* $ModDesc: Provides support for the SETHOST command */
 
 /** Handle /SETHOST
@@ -41,10 +38,15 @@ class cmd_sethost : public command_t
                {
                        if (!hostmap[(unsigned char)*x])
                        {
-                               user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
+                               user->WriteServ("NOTICE "+std::string(user->nick)+" :*** SETHOST: Invalid characters in hostname");
                                return CMD_FAILURE;
                        }
                }
+               if (len == 0)
+               {
+                       user->WriteServ("NOTICE %s :*** SETHOST: Host must be specified", user->nick);
+                       return CMD_FAILURE;
+               }
                if (len > 64)
                {
                        user->WriteServ("NOTICE %s :*** SETHOST: Host too long",user->nick);
@@ -67,9 +69,9 @@ class ModuleSetHost : public Module
        char hostmap[256];
  public:
        ModuleSetHost(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {       
-               OnRehash("");
+               OnRehash(NULL,"");
                mycommand = new cmd_sethost(ServerInstance, hostmap);
                ServerInstance->AddCommand(mycommand);
        }
@@ -79,7 +81,7 @@ class ModuleSetHost : public Module
                List[I_OnRehash] = 1;
        }
 
-       void OnRehash(const std::string &parameter)
+       void OnRehash(userrec* user, const std::string &parameter)
        {
                ConfigReader Conf(ServerInstance);
                std::string hmap = Conf.ReadValue("hostname", "charmap", 0);
@@ -103,27 +105,4 @@ class ModuleSetHost : public Module
        
 };
 
-class ModuleSetHostFactory : public ModuleFactory
-{
- public:
-       ModuleSetHostFactory()
-       {
-       }
-       
-       ~ModuleSetHostFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleSetHost(Me);
-       }
-       
-};
-
-
-extern "C" void * init_module( void )
-{
-       return new ModuleSetHostFactory;
-}
-
+MODULE_INIT(ModuleSetHost)