diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-10-02 01:47:47 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-10-02 01:47:47 +0000 |
commit | 8b9664a6af2edaa3a51dacb9fb5cfca178241289 (patch) | |
tree | 33f76c23bd16f97741bed905dbc58c86bc89608a /src | |
parent | 49e8fd6b5301e7eded8d06c720386ca3124c6180 (diff) |
IsNick moved to helperfuncs.cpp, makes a lot more sense than inspircd.cpp
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5388 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/helperfuncs.cpp | 28 | ||||
-rw-r--r-- | src/inspircd.cpp | 24 |
2 files changed, 28 insertions, 24 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 4afe7afeb..3fce34c77 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -408,6 +408,34 @@ bool InspIRCd::IsChannel(const char *chname) return true; } +bool InspIRCd::IsNick(const char* n) +{ + if (!n || !*n) + return false; + + int p = 0; + for (char* i = (char*)n; *i; i++, p++) + { + if ((*i >= 'A') && (*i <= '}')) + { + /* "A"-"}" can occur anywhere in a nickname */ + continue; + } + + if ((((*i >= '0') && (*i <= '9')) || (*i == '-')) && (i > n)) + { + /* "0"-"9", "-" can occur anywhere BUT the first char of a nickname */ + continue; + } + + /* invalid character! abort */ + return false; + } + + /* too long? or not -- pointer arithmetic rocks */ + return (p < NICKMAX - 1); +} + void InspIRCd::OpenLog(char** argv, int argc) { if (!*this->LogFileName) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 60af8e235..2f35c9528 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -708,30 +708,6 @@ bool InspIRCd::IsIdent(const char* n) } -bool InspIRCd::IsNick(const char* n) -{ - if (!n || !*n) - return false; - - int p = 0; - for (char* i = (char*)n; *i; i++, p++) - { - /* "A"-"}" can occur anywhere in a nickname */ - if ((*i >= 'A') && (*i <= '}')) - { - continue; - } - /* "0"-"9", "-" can occur anywhere BUT the first char of a nickname */ - if ((((*i >= '0') && (*i <= '9')) || (*i == '-')) && (i > n)) - { - continue; - } - /* invalid character! abort */ - return false; - } - return (p < NICKMAX - 1); -} - int InspIRCd::Run() { while (true) |