summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-22 10:14:18 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-22 10:14:18 +0000
commit4cc6e5e14fdbde499481dbab5ab2ad1257b8af9c (patch)
treedc85032f9df221bd170e5e08c3fd2a0296df2e74 /src/helperfuncs.cpp
parent9ceab65fb268ef3fbe90fbf2c37c9d20b04198cc (diff)
Move InspIRCd::IsValidMask() to helperfuncs.cpp
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8298 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index ceb4711a9..388e9bb50 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -391,6 +391,38 @@ long InspIRCd::LocalUserCount()
return (local_users.size() - this->UnregisteredUserCount());
}
+bool InspIRCd::IsValidMask(const std::string &mask)
+{
+ char* dest = (char*)mask.c_str();
+ int exclamation = 0;
+ int atsign = 0;
+
+ for (char* i = dest; *i; i++)
+ {
+ /* out of range character, bad mask */
+ if (*i < 32 || *i > 126)
+ {
+ return false;
+ }
+
+ switch (*i)
+ {
+ case '!':
+ exclamation++;
+ break;
+ case '@':
+ atsign++;
+ break;
+ }
+ }
+
+ /* valid masks only have 1 ! and @ */
+ if (exclamation != 1 || atsign != 1)
+ return false;
+
+ return true;
+}
+
/* true for valid channel name, false else */
bool InspIRCd::IsChannel(const char *chname)
{