summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-13 01:01:43 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-13 01:01:43 +0000
commita0c2e57896af9bdb7645e028c1cf13e70c5bd200 (patch)
treed3d35585dca81f9d571afdc2581efb78a83042ba /src
parentc63866b52a4052c00c8e41d5fdf7ae56cdaa438a (diff)
Added bool IsValidChannelName(const char *) - it doesn't seem to blow things up...
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3182 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/helperfuncs.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index e3e3db023..fc4ec970f 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -1465,3 +1465,36 @@ int InsertMode(std::string &output, const char* mode, unsigned short section)
output.insert(pos, mode);
return 1;
}
+
+bool IsValidChannelName(const char *chname)
+{
+ char *c;
+
+ /* check for no name - don't check for !*chname, as if it is empty, it won't be '#'! */
+ if (!chname || *chname != '#')
+ {
+ return false;
+ }
+
+ c = (char *)chname + 1;
+ while (*c)
+ {
+ switch (*c)
+ {
+ case ' ':
+ case ',':
+ case 7:
+ return false;
+ }
+
+ c++;
+ }
+
+ /* too long a name - note funky pointer arithmetic here. */
+ if ((c - chname) > CHANMAX)
+ {
+ return false;
+ }
+
+ return true;
+}