]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Was checking 'channel', not 'dest'.
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 07f9228d479323b39726572d2f529b387d605ea6..3fce34c77b39aeab247038d1c95dafe50670ed9a 100644 (file)
  */
 
 #include <stdarg.h>
-#include "inspircd_config.h"
 #include "configreader.h"
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/errno.h>
-#include <signal.h>
-#include <time.h>
-#include <string>
-#include <sstream>
-#ifdef HAS_EXECINFO
-#include <execinfo.h>
-#endif
-#include "connection.h"
 #include "users.h"
-#include "ctables.h"
-#include "globals.h"
 #include "modules.h"
-#include "dynamic.h"
 #include "wildcard.h"
 #include "mode.h"
 #include "xline.h"
-#include "commands.h"
-#include "inspstring.h"
-
-#include "hashcomp.h"
-#include "typedefs.h"
 #include "inspircd.h"
 
 static char TIMESTR[26];
@@ -428,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)