From 7578ec11e7eb18b9bf109a6eea2ff293b16db65a Mon Sep 17 00:00:00 2001 From: prozacx Date: Sat, 30 Apr 2005 19:11:07 +0000 Subject: [PATCH] Added IsValidHostName() git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@214 726aef4b-f618-498e-8847-2d620e286838 --- Server.cpp | 16 ++++++++++++++++ Server.h | 1 + 2 files changed, 17 insertions(+) diff --git a/Server.cpp b/Server.cpp index f12b0c19..f2d2dfbb 100644 --- a/Server.cpp +++ b/Server.cpp @@ -10,6 +10,22 @@ CServer::CServer(const string& sName, unsigned short uPort, const string& sPass, CServer::~CServer() {} +bool CServer::IsValidHostName(const string& sHostName) { + const char* p = sHostName.c_str(); + + if (sHostName.empty()) { + return false; + } + + while (*p) { + if (*p++ == ' ') { + return false; + } + } + + return true; +} + const string& CServer::GetName() const { return m_sName; } unsigned short CServer::GetPort() const { return m_uPort; } const string& CServer::GetPass() const { return m_sPass; } diff --git a/Server.h b/Server.h index 802abdb2..b3c843f1 100644 --- a/Server.h +++ b/Server.h @@ -12,6 +12,7 @@ public: unsigned short GetPort() const; const string& GetPass() const; bool IsSSL() const; + static bool IsValidHostName(const string& sHostName); private: protected: string m_sName;