From fd2eb26472bcc0b7b144f40523ff820cba82f574 Mon Sep 17 00:00:00 2001
From: brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Date: Thu, 10 Aug 2006 18:04:19 +0000
Subject: Move IsNick, IsIdent into class InspIRCd, update modules that use it.
 Change message.h to just a #warning saying its deprecated, and remove all use
 of it from the core :)

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4847 e03df62e-2008-0410-955e-edbf42e46eb7
---
 src/inspircd.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 52 insertions(+), 8 deletions(-)

(limited to 'src/inspircd.cpp')

diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 96518fe56..14f88e0a3 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -1,13 +1,13 @@
 /* ---------------------------------------------------------------------
  * 
- *              +------------------------------------+
- *              | Inspire Internet Relay Chat Daemon |
- *              +------------------------------------+
+ *	      +------------------------------------+
+ *	      | Inspire Internet Relay Chat Daemon |
+ *	      +------------------------------------+
  *
- *         InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                             E-mail:
- *                      <brain@chatspike.net>
- *                      <Craig@chatspike.net>
+ *	 InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
+ *			     E-mail:
+ *		      <brain@chatspike.net>
+ *		      <Craig@chatspike.net>
  *     
  *  Written by Craig Edwards, Craig McLure, and others.
  *  This program is free but copyrighted software; you can redistribute
@@ -51,7 +51,6 @@
 #include "modules.h"
 #include "dynamic.h"
 #include "wildcard.h"
-#include "message.h"
 #include "mode.h"
 #include "commands.h"
 #include "xline.h"
@@ -889,6 +888,51 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
 	}
 }
 
+bool InspIRCd::IsIdent(const char* n)
+{
+	if (!n || !*n)
+		return false;
+
+	for (char* i = (char*)n; *i; i++)
+	{
+		if ((*i >= 'A') && (*i <= '}'))
+		{
+			continue;
+		}
+		if (((*i >= '0') && (*i <= '9')) || (*i == '-') || (*i == '.'))
+		{
+			continue;
+		}
+		return false;
+	}
+	return true;
+}
+
+
+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()
 {
 	this->Res = new DNS(this);
-- 
cgit v1.2.3