summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-07-24 20:21:29 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-07-24 20:21:29 +0000
commitc88d4a3511cd9706b5c02c576b0445f13391afd3 (patch)
tree601df768ed6050351a48b2e914f223e6d4fe8bea
parent2f44ee5b2a4b44cc7005ed76eaeef8c136713153 (diff)
Replace some voodoo with a define
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7556 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/inspircd.h5
-rw-r--r--src/command_parse.cpp12
-rw-r--r--src/modules/m_alias.cpp6
-rw-r--r--src/modules/m_filter.h2
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp2
5 files changed, 16 insertions, 11 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index b0382e473..f21e03272 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -38,6 +38,11 @@
#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
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 7a89cc4ca..84850a880 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -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++;
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 94c64b405..a8f079bf1 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -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++;
diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h
index 576269325..5e74177e5 100644
--- a/src/modules/m_filter.h
+++ b/src/modules/m_filter.h
@@ -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";
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 23362ca99..a321ee36b 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -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);