git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3182
e03df62e-2008-0410-955e-
edbf42e46eb7
bool AllModulesReportReady(userrec* user);
bool DirValid(char* dirandfile);
std::string GetFullProgDir(char** argv, int argc);
-
int InsertMode(std::string &output, const char* modes, unsigned short section);
+bool IsValidChannelName(const char *);
#endif
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;
+}