]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Replace some voodoo with a define
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 24 Jul 2007 20:21:29 +0000 (20:21 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 24 Jul 2007 20:21:29 +0000 (20:21 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7556 e03df62e-2008-0410-955e-edbf42e46eb7

include/inspircd.h
src/command_parse.cpp
src/modules/m_alias.cpp
src/modules/m_filter.h
src/modules/m_spanningtree/treesocket2.cpp

index b0382e473e1de579e4311b459fe370409fb348dd..f21e0327264ed0ad40d3df384233f2c4a766787b 100644 (file)
 #include "snomasks.h"
 #include "cull_list.h"
 
+/**
+ * Used to define the maximum number of parameters a command may have.
+ */
+#define MAXPARAMETERS 127
+
 /** Returned by some functions to indicate failure.
  */
 #define ERROR -1
index 7a89cc4cae2c0437937770138e6d5cb49c0cc15b..84850a880fb564d7e95895903f0e2c198593d71d 100644 (file)
@@ -144,9 +144,9 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p
        {
                if (dupes.find(item.c_str()) == dupes.end())
                {
-                       const char* new_parameters[127];
+                       const char* new_parameters[MAXPARAMETERS];
 
-                       for (int t = 0; (t < pcnt) && (t < 127); t++)
+                       for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
                                new_parameters[t] = parameters[t];
 
                        std::string extrastuff = items2.GetToken();
@@ -185,9 +185,9 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p
        {
                if (dupes.find(item.c_str()) == dupes.end())
                {
-                       const char* new_parameters[127];
+                       const char* new_parameters[MAXPARAMETERS];
 
-                       for (int t = 0; (t < pcnt) && (t < 127); t++)
+                       for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
                                new_parameters[t] = parameters[t];
 
                        new_parameters[splithere] = item.c_str();
@@ -271,7 +271,7 @@ CmdResult CommandParser::CallHandler(const std::string &commandname,const char**
 
 void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
 {
-       const char *command_p[127];
+       const char *command_p[MAXPARAMETERS];
        int items = 0;
        irc::tokenstream tokens(cmd);
        std::string command;
@@ -285,7 +285,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
        if (*command.c_str() == ':')
                tokens.GetToken(command);
 
-       while (tokens.GetToken(para[items]) && (items < 127))
+       while (tokens.GetToken(para[items]) && (items < MAXPARAMETERS))
        {
                command_p[items] = para[items].c_str();
                items++;
index 94c64b4055868754377e406f6f7ba9d19f9aa173..a8f079bf1c808dae7faaf41770ab7eeea9e65cec 100644 (file)
@@ -77,7 +77,7 @@ class ModuleAlias : public Module
                : Module(Me)
        {
                ReadAliases();
-               pars.resize(127);
+               pars.resize(MAXPARAMETERS);
        }
 
        void Implements(char* List)
@@ -251,10 +251,10 @@ class ModuleAlias : public Module
                SearchAndReplace(newline, "\r", "$");
 
                irc::tokenstream ss(newline);
-               const char* parv[127];
+               const char* parv[MAXPARAMETERS];
                int x = 0;
 
-               while (ss.GetToken(pars[x]))
+               while (ss.GetToken(pars[x]) && x < MAXPARAMETERS)
                {
                        parv[x] = pars[x].c_str();
                        x++;
index 576269325dbd4ff14e2c781ec6d965cc96a015f9..5e74177e5073ce59ccadd902c4d1074cd518a1c7 100644 (file)
@@ -341,7 +341,7 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters
                command_t* c = ServerInstance->Parser->GetHandler(command);
                if (c)
                {
-                       const char* params[127];
+                       const char* params[MAXPARAMETERS];
                        for (int item = 0; item < pcnt; item++)
                                params[item] = parameters[item];
                        params[replacepoint] = "Reason filtered";
index 23362ca9932dc6bf8c07ef5f8030290f7714cd57..a321ee36b6d8f83084724c9a3c0289674d72ca65 100644 (file)
@@ -1400,7 +1400,7 @@ bool TreeSocket::ProcessLine(std::string &line)
                                {
                                        if (Utils->IsServer(prefix))
                                        {
-                                               const char* modelist[127];
+                                               const char* modelist[MAXPARAMETERS];
                                                for (size_t i = 0; i < params.size(); i++)
                                                        modelist[i] = params[i].c_str();
                                                userrec* fake = new userrec(Instance);