summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-25 17:30:43 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-25 17:30:43 +0000
commit7d7250484c352c13830e63ae41ee8faae40a9bd5 (patch)
tree0fdf4941b4d72469a18eec97506f06f6e94e86e9 /src/helperfuncs.cpp
parente7b837ec5f120f928a0dc321fa918bdd01ab0c02 (diff)
First phase of conversion to dynamic limits on all the lengths, configured via the <limits> tag
(the tag isnt there yet, these all just run on defaults in the class constructor) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9802 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 8b93be245..d46f53ec7 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -182,9 +182,9 @@ bool InspIRCd::IsValidMask(const std::string &mask)
}
/* true for valid channel name, false else */
-bool IsChannelHandler::Call(const char *chname)
+bool IsChannelHandler::Call(const char *chname, size_t max)
{
- char *c;
+ const char *c = chname + 1;
/* check for no name - don't check for !*chname, as if it is empty, it won't be '#'! */
if (!chname || *chname != '#')
@@ -192,7 +192,6 @@ bool IsChannelHandler::Call(const char *chname)
return false;
}
- c = (char *)chname + 1;
while (*c)
{
switch (*c)
@@ -205,9 +204,10 @@ bool IsChannelHandler::Call(const char *chname)
c++;
}
-
+
+ size_t len = c - chname;
/* too long a name - note funky pointer arithmetic here. */
- if ((c - chname) > CHANMAX)
+ if (len > max)
{
return false;
}
@@ -216,13 +216,13 @@ bool IsChannelHandler::Call(const char *chname)
}
/* true for valid nickname, false else */
-bool IsNickHandler::Call(const char* n)
+bool IsNickHandler::Call(const char* n, size_t max)
{
if (!n || !*n)
return false;
- int p = 0;
- for (char* i = (char*)n; *i; i++, p++)
+ unsigned int p = 0;
+ for (const char* i = n; *i; i++, p++)
{
if ((*i >= 'A') && (*i <= '}'))
{
@@ -241,7 +241,7 @@ bool IsNickHandler::Call(const char* n)
}
/* too long? or not -- pointer arithmetic rocks */
- return (p < NICKMAX - 1);
+ return (p < max);
}
/* return true for good ident, false else */
@@ -250,7 +250,7 @@ bool IsIdentHandler::Call(const char* n)
if (!n || !*n)
return false;
- for (char* i = (char*)n; *i; i++)
+ for (const char* i = n; *i; i++)
{
if ((*i >= 'A') && (*i <= '}'))
{