]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_svshold.cpp
Conversions. :D
[user/henk/code/inspircd.git] / src / modules / m_svshold.cpp
index abef3d713f11a8b3052b435089e9930858f6c127..a056c9d84e2a5c0300c98cdff6a50fa9a4661f78 100644 (file)
  * ---------------------------------------------------
  */
 
+#include "inspircd.h"
 #include <algorithm>
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
 #include "configreader.h"
-#include "inspircd.h"
 
 /* $ModDesc: Implements SVSHOLD. Like Q:Lines, but can only be added/removed by Services. */
 
@@ -66,6 +66,12 @@ class cmd_svshold : public command_t
                /* syntax: svshold nickname time :reason goes here */
                /* 'time' is a human-readable timestring, like 2d3h2s. */
 
+               if (!ServerInstance->ULine(user->server))
+               {
+                       /* don't allow SVSHOLD from non-ulined clients */
+                       return CMD_FAILURE;
+               }
+
                if (pcnt == 1)
                {
                        SVSHoldMap::iterator n = HoldMap.find(parameters[0]);
@@ -84,7 +90,7 @@ class cmd_svshold : public command_t
                                                }
                                                else
                                                {
-                                                       user->WriteServ( "386 %s %s :Removed permenant SVSHOLD (%s)", user->nick, (*iter)->nickname.c_str(), (*iter)->reason.c_str());
+                                                       user->WriteServ( "386 %s %s :Removed permanent SVSHOLD (%s)", user->nick, (*iter)->nickname.c_str(), (*iter)->reason.c_str());
                                                }
                                                SVSHolds.erase(iter);
                                                break;
@@ -153,7 +159,7 @@ class ModuleSVSHold : public Module
        
 
  public:
-       ModuleSVSHold(InspIRCd* Me) : Module::Module(Me)
+       ModuleSVSHold(InspIRCd* Me) : Module(Me)
        {
                mycommand = new cmd_svshold(Me);
                ServerInstance->AddCommand(mycommand);
@@ -232,19 +238,21 @@ class ModuleSVSHold : public Module
        std::string EncodeSVSHold(const SVSHold* ban)
        {
                std::ostringstream stream;      
-               stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " " << ban->reason;
+               stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " :" << ban->reason;
                return stream.str();    
        }
 
        SVSHold* DecodeSVSHold(const std::string &data)
        {
                SVSHold* res = new SVSHold();
-               std::istringstream stream(data);
-               stream >> res->nickname;
-               stream >> res->set_by;
-               stream >> res->set_on;
-               stream >> res->length;
-               res->reason = stream.str();
+               int set_on;
+               irc::tokenstream tokens(data);
+               tokens.GetToken(res->nickname);
+               tokens.GetToken(res->set_by);
+               tokens.GetToken(set_on);
+               res->set_on = set_on;
+               tokens.GetToken(res->length);
+               tokens.GetToken(res->reason);
                return res;
        }
 
@@ -271,26 +279,4 @@ class ModuleSVSHold : public Module
        }
 };
 
-class ModuleSVSHoldFactory : public ModuleFactory
-{
- public:
-       ModuleSVSHoldFactory()
-       {
-       }
-       
-       ~ModuleSVSHoldFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleSVSHold(Me);
-       }
-       
-};
-
-
-extern "C" void * init_module( void )
-{
-       return new ModuleSVSHoldFactory;
-}
+MODULE_INIT(ModuleSVSHold);