From 7024834f11e353cd66df0af29bb1471bdb9ba8fc Mon Sep 17 00:00:00 2001 From: prozacx Date: Thu, 28 Apr 2005 07:29:50 +0000 Subject: [PATCH] Added Find/DelServer() git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@196 726aef4b-f618-498e-8847-2d620e286838 --- User.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/User.cpp b/User.cpp index d4c81986..1a4d444c 100644 --- a/User.cpp +++ b/User.cpp @@ -136,14 +136,41 @@ bool CUser::DelChan(const string& sName) { CChan* CUser::FindChan(const string& sName) { for (unsigned int a = 0; a < m_vChans.size(); a++) { - if (strcasecmp(sName.c_str(), m_vChans[a]->GetName().c_str()) == 0) { - return m_vChans[a]; + CChan* pChan = m_vChans[a]; + if (strcasecmp(sName.c_str(), pChan->GetName().c_str()) == 0) { + return pChan; } } return NULL; } +CServer* CUser::FindServer(const string& sName) { + for (unsigned int a = 0; a < m_vServers.size(); a++) { + CServer* pServer = m_vServers[a]; + if (strcasecmp(sName.c_str(), pServer->GetName().c_str()) == 0) { + return pServer; + } + } + + return NULL; +} + +bool CUser::DelServer(const string& sName) { + if (sName.empty()) { + return false; + } + + for (vector::iterator it = m_vServers.begin(); it != m_vServers.end(); it++) { + if (strcasecmp((*it)->GetName().c_str(), sName.c_str()) == 0) { + m_vServers.erase(it); + return true; + } + } + + return false; +} + bool CUser::AddServer(const string& sName) { if (sName.empty()) { return false; @@ -441,6 +468,7 @@ bool CUser::DenyLoadMod() const { return m_bDenyLoadMod; } const string& CUser::GetStatusPrefix() const { return m_sStatusPrefix; } const string& CUser::GetDefaultChanModes() const { return m_sDefaultChanModes; } const vector& CUser::GetChans() const { return m_vChans; } +const vector& CUser::GetServers() const { return m_vServers; } const CNick& CUser::GetIRCNick() const { return m_IRCNick; } const string& CUser::GetIRCServer() const { return m_sIRCServer; } const string& CUser::GetQuitMsg() const { return m_sQuitMsg; }