From: <kr...@us...> - 2008-09-30 15:16:57
|
Revision: 1234 http://znc.svn.sourceforge.net/znc/?rev=1234&view=rev Author: kroimon Date: 2008-09-30 15:15:59 +0000 (Tue, 30 Sep 2008) Log Message: ----------- Use CString::Equals() everywhere. * (CString::CaseCmp() == 0) became CString::Equals() * (CString::CaseCmp() != 0) became !CString::Equals() * replaced some occurrences of strn?casecmp Modified Paths: -------------- trunk/Chan.cpp trunk/Client.cpp trunk/ClientCommand.cpp trunk/HTTPSock.cpp trunk/IRCSock.cpp trunk/Modules.cpp trunk/Nick.cpp trunk/Template.cpp trunk/User.cpp trunk/Utils.cpp trunk/ZNCString.cpp trunk/modules/autoattach.cpp trunk/modules/autocycle.cpp trunk/modules/autoop.cpp trunk/modules/awaynick.cpp trunk/modules/crypt.cpp trunk/modules/email.cpp trunk/modules/imapauth.cpp trunk/modules/keepnick.cpp trunk/modules/kickrejoin.cpp trunk/modules/modperl.cpp trunk/modules/nickserv.cpp trunk/modules/partyline.cpp trunk/modules/perform.cpp trunk/modules/q.cpp trunk/modules/sample.cpp trunk/modules/savebuff.cpp trunk/modules/schat.cpp trunk/modules/shell.cpp trunk/modules/simple_away.cpp trunk/modules/stickychan.cpp trunk/modules/watch.cpp trunk/modules/webadmin.cpp trunk/znc.cpp Modified: trunk/Chan.cpp =================================================================== --- trunk/Chan.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/Chan.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -269,7 +269,7 @@ IncPermCount(uPerm); } - if (pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0) { + if (pNick->GetNick().Equals(m_pUser->GetCurNick())) { AddPerm(uPerm); } } else { @@ -277,7 +277,7 @@ DecPermCount(uPerm); } - if (pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0) { + if (pNick->GetNick().Equals(m_pUser->GetCurNick())) { RemPerm(uPerm); } } @@ -466,7 +466,7 @@ } } - if (pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0) { + if (pNick->GetNick().Equals(m_pUser->GetCurNick())) { for (CString::size_type i = 0; i < sPrefix.length(); i++) { AddPerm(sPrefix[i]); } Modified: trunk/Client.cpp =================================================================== --- trunk/Client.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/Client.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -83,7 +83,7 @@ sCommand = sLine.Token(0); } - if (sCommand.CaseCmp("PASS") == 0) { + if (sCommand.Equals("PASS")) { if (!IsAttached()) { m_bGotPass = true; m_sPass = sLine.Token(1); @@ -99,7 +99,7 @@ return; // Don't forward this msg. ZNC has already registered us. } - } else if (sCommand.CaseCmp("NICK") == 0) { + } else if (sCommand.Equals("NICK")) { CString sNick = sLine.Token(1); if (sNick.Left(1) == ":") { sNick.LeftChomp(); @@ -119,7 +119,7 @@ // No need to forward it return; } - } else if (sCommand.CaseCmp("USER") == 0) { + } else if (sCommand.Equals("USER")) { if (!IsAttached()) { if (m_sUser.empty()) { m_sUser = sLine.Token(1); @@ -144,7 +144,7 @@ return; } - if (sCommand.CaseCmp("ZNC") == 0) { + if (sCommand.Equals("ZNC")) { CString sTarget = sLine.Token(1); CString sModCommand; @@ -155,7 +155,7 @@ sModCommand = sLine.Token(1, true); } - if (sTarget.CaseCmp("status") == 0) { + if (sTarget.Equals("status")) { if (sModCommand.empty()) PutStatus("Hello. How may I help you?"); else @@ -169,7 +169,7 @@ #endif } return; - } else if (sCommand.CaseCmp("DETACH") == 0) { + } else if (sCommand.Equals("DETACH")) { CString sChan = sLine.Token(1); if (sChan.empty()) { @@ -186,19 +186,19 @@ pChan->DetachUser(); PutStatusNotice("Detached from [" + sChan + "]"); return; - } else if (sCommand.CaseCmp("PING") == 0) { + } else if (sCommand.Equals("PING")) { CString sTarget = sLine.Token(1); // If the client meant to ping us or we can be sure the server // won't answer the ping (=no server connected) -> PONG back. // else: It's the server's job to send a PONG. - if (sTarget.CaseCmp("irc.znc.in") == 0 || !m_pIRCSock) { + if (sTarget.Equals("irc.znc.in") || !m_pIRCSock) { PutClient("PONG " + sLine.substr(5)); return; } - } else if (sCommand.CaseCmp("PONG") == 0) { + } else if (sCommand.Equals("PONG")) { return; // Block pong replies, we already responded to the pings - } else if (sCommand.CaseCmp("JOIN") == 0) { + } else if (sCommand.Equals("JOIN")) { CString sChans = sLine.Token(1); CString sKey = sLine.Token(2); @@ -235,7 +235,7 @@ if (!sKey.empty()) { sLine += " " + sKey; } - } else if (sCommand.CaseCmp("PART") == 0) { + } else if (sCommand.Equals("PART")) { CString sChan = sLine.Token(1); CString sMessage = sLine.Token(2, true); @@ -262,7 +262,7 @@ if (!sMessage.empty()) { sLine += " :" + sMessage; } - } else if (sCommand.CaseCmp("TOPIC") == 0) { + } else if (sCommand.Equals("TOPIC")) { CString sChan = sLine.Token(1); CString sTopic = sLine.Token(2, true); @@ -274,7 +274,7 @@ } else { MODULECALL(OnUserTopicRequest(sChan), m_pUser, this, return); } - } else if (sCommand.CaseCmp("MODE") == 0) { + } else if (sCommand.Equals("MODE")) { CString sTarget = sLine.Token(1); CString sModes = sLine.Token(2, true); @@ -289,23 +289,23 @@ return; } } - } else if (sCommand.CaseCmp("QUIT") == 0) { + } else if (sCommand.Equals("QUIT")) { m_pUser->UserDisconnected(this); Close(); // Treat a client quit as a detach return; // Don't forward this msg. We don't want the client getting us disconnected. - } else if (sCommand.CaseCmp("PROTOCTL") == 0) { + } else if (sCommand.Equals("PROTOCTL")) { unsigned int i = 1; while (!sLine.Token(i).empty()) { - if (sLine.Token(i).CaseCmp("NAMESX") == 0) { + if (sLine.Token(i).Equals("NAMESX")) { m_bNamesx = true; - } else if (sLine.Token(i).CaseCmp("UHNAMES") == 0) { + } else if (sLine.Token(i).Equals("UHNAMES")) { m_bUHNames = true; } i++; } return; // If the server understands it, we already enabled namesx / uhnames - } else if (sCommand.CaseCmp("NOTICE") == 0) { + } else if (sCommand.Equals("NOTICE")) { CString sTarget = sLine.Token(1); CString sMsg = sLine.Token(2, true); @@ -315,7 +315,7 @@ if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) { #ifdef _MODULES - if (sTarget.CaseCmp("status") != 0) { + if (!sTarget.Equals("status")) { CALLMOD(sTarget, this, m_pUser, OnModNotice(sMsg)); } #endif @@ -342,7 +342,7 @@ if (!m_pIRCSock) { // Some lagmeters do a NOTICE to their own nick, ignore those. - if (sTarget.CaseCmp(m_sNick) != 0) + if (!sTarget.Equals(m_sNick)) PutStatus("Your notice to [" + sTarget + "] got lost, " "you are not connected to IRC!"); return; @@ -369,7 +369,7 @@ PutIRC("NOTICE " + sTarget + " :" + sMsg); return; - } else if (sCommand.CaseCmp("PRIVMSG") == 0) { + } else if (sCommand.Equals("PRIVMSG")) { CString sTarget = sLine.Token(1); CString sMsg = sLine.Token(2, true); @@ -382,7 +382,7 @@ sCTCP.LeftChomp(); sCTCP.RightChomp(); - if (sCTCP.CaseCmp("DCC ", 4) == 0 && m_pUser->BounceDCCs()) { + if (sCTCP.Equals("DCC ", false, 4) && m_pUser->BounceDCCs()) { CString sType = sCTCP.Token(1); CString sFile = sCTCP.Token(2); unsigned long uLongIP = strtoul(sCTCP.Token(3).c_str(), NULL, 10); @@ -394,18 +394,18 @@ uLongIP = CUtils::GetLongIP(GetRemoteIP()); } - if (sType.CaseCmp("CHAT") == 0) { + if (sType.Equals("CHAT")) { if (!sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) { unsigned short uBNCPort = CDCCBounce::DCCRequest(sTarget, uLongIP, uPort, "", true, m_pUser, (m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP(), ""); if (uBNCPort) { PutIRC("PRIVMSG " + sTarget + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + "\001"); } } - } else if (sType.CaseCmp("SEND") == 0) { + } else if (sType.Equals("SEND")) { // DCC SEND readme.txt 403120438 5550 1104 if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) { - if (sTarget.CaseCmp("status") == 0) { + if (sTarget.Equals("status")) { CString sPath = m_pUser->GetDLPath(); if (!CFile::Exists(sPath)) { PutStatus("Could not create [" + sPath + "] directory."); @@ -427,14 +427,14 @@ PutIRC("PRIVMSG " + sTarget + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001"); } } - } else if (sType.CaseCmp("RESUME") == 0) { + } else if (sType.Equals("RESUME")) { // PRIVMSG user :DCC RESUME "znc.o" 58810 151552 unsigned short uResumePort = atoi(sCTCP.Token(3).c_str()); unsigned long uResumeSize = strtoul(sCTCP.Token(4).c_str(), NULL, 10); // Need to lookup the connection by port, filter the port, and forward to the user CString sStatusPrefix = m_pUser->GetStatusPrefix(); - if (sTarget.CaseCmp(sStatusPrefix, sStatusPrefix.length()) == 0) { + if (sTarget.Equals(sStatusPrefix, false, sStatusPrefix.length())) { if (m_pUser->ResumeFile(uResumePort, uResumeSize)) { PutClient(":" + sTarget + "!zn...@zn... PRIVMSG " + GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString(uResumePort) + " " + CString(uResumeSize) + "\001"); } else { @@ -442,20 +442,20 @@ } } else { CDCCBounce* pSock = (CDCCBounce*) CZNC::Get().GetManager().FindSockByLocalPort(uResumePort); - if ((pSock) && (pSock->GetSockName().CaseCmp("DCC::", 5) == 0)) { + if (pSock && pSock->GetSockName().Equals("DCC::", false, 5)) { PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sCTCP.Token(4) + "\001"); } } - } else if (sType.CaseCmp("ACCEPT") == 0) { + } else if (sType.Equals("ACCEPT")) { CString sStatusPrefix = m_pUser->GetStatusPrefix(); - if (sTarget.CaseCmp(sStatusPrefix, sStatusPrefix.length()) != 0) { + if (!sTarget.Equals(sStatusPrefix, false, sStatusPrefix.length())) { // Need to lookup the connection by port, filter the port, and forward to the user CSockManager& Manager = CZNC::Get().GetManager(); for (unsigned int a = 0; a < Manager.size(); a++) { CDCCBounce* pSock = (CDCCBounce*) Manager[a]; - if ((pSock) && (pSock->GetSockName().CaseCmp("DCC::", 5) == 0)) { + if (pSock && pSock->GetSockName().Equals("DCC::", false, 5)) { if (pSock->GetUserPort() == atoi(sCTCP.Token(3).c_str())) { PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sCTCP.Token(4) + "\001"); } @@ -468,7 +468,7 @@ } if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) { - if (sTarget.CaseCmp("status") == 0) { + if (sTarget.Equals("status")) { StatusCTCP(sCTCP); } else { #ifdef _MODULES @@ -480,7 +480,7 @@ CChan* pChan = m_pUser->FindChan(sTarget); - if (sCTCP.Token(0).CaseCmp("ACTION") == 0) { + if (sCTCP.Token(0).Equals("ACTION")) { CString sMessage = sCTCP.Token(1, true); MODULECALL(OnUserAction(sTarget, sMessage), m_pUser, this, return); sCTCP = "ACTION " + sMessage; @@ -510,7 +510,7 @@ } if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) { - if (sTarget.CaseCmp("status") == 0) { + if (sTarget.Equals("status")) { MODULECALL(OnStatusCommand(sMsg), m_pUser, this, return); UserCommand(sMsg); } else { @@ -525,7 +525,7 @@ if (!m_pIRCSock) { // Some lagmeters do a PRIVMSG to their own nick, ignore those. - if (sTarget.CaseCmp(m_sNick) != 0) + if (!sTarget.Equals(m_sNick)) PutStatus("Your message to [" + sTarget + "] got lost, " "you are not connected to IRC!"); return; @@ -566,9 +566,9 @@ void CClient::StatusCTCP(const CString& sLine) { CString sCommand = sLine.Token(0); - if (sCommand.CaseCmp("PING") == 0) { + if (sCommand.Equals("PING")) { PutStatusNotice("\001PING " + sLine.Token(1, true) + "\001"); - } else if (sCommand.CaseCmp("VERSION") == 0) { + } else if (sCommand.Equals("VERSION")) { PutStatusNotice("\001VERSION " + CZNC::GetTag() + "\001"); } } Modified: trunk/ClientCommand.cpp =================================================================== --- trunk/ClientCommand.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/ClientCommand.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -26,9 +26,9 @@ CString sCommand = sLine.Token(0); - if (sCommand.CaseCmp("HELP") == 0) { + if (sCommand.Equals("HELP")) { HelpUser(); - } else if (sCommand.CaseCmp("LISTNICKS") == 0) { + } else if (sCommand.Equals("LISTNICKS")) { CString sChan = sLine.Token(1); if (sChan.empty()) { @@ -86,7 +86,7 @@ } PutStatus(Table); - } else if (sCommand.CaseCmp("DETACH") == 0) { + } else if (sCommand.Equals("DETACH")) { CString sChan = sLine.Token(1); if (sChan.empty()) { @@ -102,13 +102,13 @@ PutStatus("Detaching you from [" + sChan + "]"); pChan->DetachUser(); - } else if (sCommand.CaseCmp("VERSION") == 0) { + } else if (sCommand.Equals("VERSION")) { PutStatus(CZNC::GetTag()); - } else if (sCommand.CaseCmp("MOTD") == 0 || sCommand.CaseCmp("ShowMOTD") == 0) { + } else if (sCommand.Equals("MOTD") || sCommand.Equals("ShowMOTD")) { if (!SendMotd()) { PutStatus("There is no MOTD set."); } - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("Rehash") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("Rehash")) { CString sRet; if (CZNC::Get().RehashConfig(sRet)) { @@ -116,13 +116,13 @@ } else { PutStatus("Rehashing failed: " + sRet); } - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("SaveConfig") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("SaveConfig")) { if (CZNC::Get().WriteConfig()) { PutStatus("Wrote config to [" + CZNC::Get().GetConfigFile() + "]"); } else { PutStatus("Error while trying to write config."); } - } else if (sCommand.CaseCmp("LISTCLIENTS") == 0) { + } else if (sCommand.Equals("LISTCLIENTS")) { CUser* pUser = m_pUser; CString sNick = sLine.Token(1); @@ -156,7 +156,7 @@ } PutStatus(Table); - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("LISTUSERS") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("LISTUSERS")) { const map<CString, CUser*>& msUsers = CZNC::Get().GetUserMap(); CTable Table; Table.AddColumn("Username"); @@ -179,7 +179,7 @@ } PutStatus(Table); - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("SetMOTD") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("SetMOTD")) { CString sMessage = sLine.Token(1, true); if (sMessage.empty()) { @@ -188,7 +188,7 @@ CZNC::Get().SetMotd(sMessage); PutStatus("MOTD set to [" + sMessage + "]"); } - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("AddMOTD") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("AddMOTD")) { CString sMessage = sLine.Token(1, true); if (sMessage.empty()) { @@ -197,12 +197,12 @@ CZNC::Get().AddMotd(sMessage); PutStatus("Added [" + sMessage + "] to MOTD"); } - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("ClearMOTD") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("ClearMOTD")) { CZNC::Get().ClearMotd(); PutStatus("Cleared MOTD"); - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("BROADCAST") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("BROADCAST")) { CZNC::Get().Broadcast(sLine.Token(1, true)); - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("SHUTDOWN") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("SHUTDOWN")) { CString sMessage = sLine.Token(1, true); if (sMessage.empty()) { @@ -213,7 +213,7 @@ usleep(100000); // Sleep for 10ms to attempt to allow the previous Broadcast() to go through to all users throw CException(CException::EX_Shutdown); - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("RESTART") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("RESTART")) { CString sMessage = sLine.Token(1, true); if (sMessage.empty()) { @@ -222,8 +222,7 @@ CZNC::Get().Broadcast(sMessage); throw CException(CException::EX_Restart); - } else if (sCommand.CaseCmp("JUMP") == 0 || - sCommand.CaseCmp("CONNECT") == 0) { + } else if (sCommand.Equals("JUMP") || sCommand.Equals("CONNECT")) { if (!m_pUser->HasServers()) { PutStatus("You don't have any servers added."); return; @@ -239,7 +238,7 @@ m_pUser->SetIRCConnectEnabled(true); m_pUser->CheckIRCConnect(); return; - } else if (sCommand.CaseCmp("DISCONNECT") == 0) { + } else if (sCommand.Equals("DISCONNECT")) { // m_pIRCSock is only set after the low level connection // to the IRC server was established. Before this we can // only find the IRC socket by its name. @@ -257,7 +256,7 @@ m_pUser->SetIRCConnectEnabled(false); PutStatus("Disconnected from IRC. Use 'connect' to reconnect."); return; - } else if (sCommand.CaseCmp("ENABLECHAN") == 0) { + } else if (sCommand.Equals("ENABLECHAN")) { CString sChan = sLine.Token(1, true); if (sChan.empty()) { @@ -272,7 +271,7 @@ pChan->Enable(); PutStatus("Channel [" + sChan + "] enabled."); } - } else if (sCommand.CaseCmp("LISTCHANS") == 0) { + } else if (sCommand.Equals("LISTCHANS")) { const vector<CChan*>& vChans = m_pUser->GetChans(); CIRCSock* pIRCSock = (!m_pUser) ? NULL : m_pUser->GetIRCSock(); const CString& sPerms = (pIRCSock) ? pIRCSock->GetPerms() : ""; @@ -314,7 +313,7 @@ } PutStatus(Table); - } else if (sCommand.CaseCmp("ADDSERVER") == 0) { + } else if (sCommand.Equals("ADDSERVER")) { CString sServer = sLine.Token(1); if (sServer.empty()) { @@ -332,7 +331,7 @@ } else { PutStatus("Unable to add that server"); } - } else if (sCommand.CaseCmp("REMSERVER") == 0 || sCommand.CaseCmp("DELSERVER") == 0) { + } else if (sCommand.Equals("REMSERVER") || sCommand.Equals("DELSERVER")) { CString sServer = sLine.Token(1); if (sServer.empty()) { @@ -352,7 +351,7 @@ } else { PutStatus("No such server"); } - } else if (sCommand.CaseCmp("LISTSERVERS") == 0) { + } else if (sCommand.Equals("LISTSERVERS")) { if (m_pUser->HasServers()) { const vector<CServer*>& vServers = m_pUser->GetServers(); CTable Table; @@ -374,7 +373,7 @@ } else { PutStatus("You don't have any servers added."); } - } else if (sCommand.CaseCmp("TOPICS") == 0) { + } else if (sCommand.Equals("TOPICS")) { const vector<CChan*>& vChans = m_pUser->GetChans(); CTable Table; Table.AddColumn("Name"); @@ -390,7 +389,7 @@ } PutStatus(Table); - } else if (sCommand.CaseCmp("SEND") == 0) { + } else if (sCommand.Equals("SEND")) { CString sToNick = sLine.Token(1); CString sFile = sLine.Token(2); CString sAllowedPath = m_pUser->GetDLPath(); @@ -409,7 +408,7 @@ } m_pUser->SendFile(sToNick, sFile); - } else if (sCommand.CaseCmp("GET") == 0) { + } else if (sCommand.Equals("GET")) { CString sFile = sLine.Token(1); CString sAllowedPath = m_pUser->GetDLPath(); CString sAbsolutePath; @@ -427,7 +426,7 @@ } m_pUser->SendFile(GetNick(), sFile); - } else if (sCommand.CaseCmp("LISTDCCS") == 0) { + } else if (sCommand.Equals("LISTDCCS")) { CSockManager& Manager = CZNC::Get().GetManager(); CTable Table; @@ -439,18 +438,18 @@ Table.AddColumn("File"); for (unsigned int a = 0; a < Manager.size(); a++) { - const CString& sSockName = Manager[a]->GetSockName(); + CString sSockName = Manager[a]->GetSockName(); - if (strncasecmp(sSockName.c_str(), "DCC::", 5) == 0) { - if (strncasecmp(sSockName.c_str() +5, "XFER::REMOTE::", 14) == 0) { + if (sSockName.TrimPrefix("DCC::")) { + if (sSockName.Equals("XFER::REMOTE::", false, 14)) { continue; } - if (strncasecmp(sSockName.c_str() +5, "CHAT::REMOTE::", 14) == 0) { + if (sSockName.Equals("CHAT::REMOTE::", false, 14)) { continue; } - if (strncasecmp(sSockName.c_str() +5, "SEND", 4) == 0) { + if (sSockName.Equals("SEND", false, 4)) { CDCCSock* pSock = (CDCCSock*) Manager[a]; Table.AddRow(); @@ -460,7 +459,7 @@ Table.SetCell("Nick", pSock->GetRemoteNick()); Table.SetCell("IP", pSock->GetRemoteIP()); Table.SetCell("File", pSock->GetFileName()); - } else if (strncasecmp(sSockName.c_str() +5, "GET", 3) == 0) { + } else if (sSockName.Equals("GET", false, 3)) { CDCCSock* pSock = (CDCCSock*) Manager[a]; Table.AddRow(); @@ -470,7 +469,7 @@ Table.SetCell("Nick", pSock->GetRemoteNick()); Table.SetCell("IP", pSock->GetRemoteIP()); Table.SetCell("File", pSock->GetFileName()); - } else if (strncasecmp(sSockName.c_str() +5, "LISTEN", 6) == 0) { + } else if (sSockName.Equals("LISTEN", false, 6)) { CDCCSock* pSock = (CDCCSock*) Manager[a]; Table.AddRow(); @@ -479,7 +478,7 @@ Table.SetCell("Nick", pSock->GetRemoteNick()); Table.SetCell("IP", pSock->GetRemoteIP()); Table.SetCell("File", pSock->GetFileName()); - } else if (strncasecmp(sSockName.c_str() +5, "XFER::LOCAL", 11) == 0) { + } else if (sSockName.Equals("XFER::LOCAL", false, 11)) { CDCCBounce* pSock = (CDCCBounce*) Manager[a]; CString sState = "Waiting"; @@ -496,7 +495,7 @@ Table.SetCell("Nick", pSock->GetRemoteNick()); Table.SetCell("IP", pSock->GetRemoteIP()); Table.SetCell("File", pSock->GetFileName()); - } else if (strncasecmp(sSockName.c_str() +5, "CHAT::LOCAL", 11) == 0) { + } else if (sSockName.Equals("CHAT::LOCAL", false, 11)) { CDCCBounce* pSock = (CDCCBounce*) Manager[a]; CString sState = "Waiting"; @@ -519,7 +518,7 @@ if (PutStatus(Table) == 0) { PutStatus("You have no active DCCs."); } - } else if ((sCommand.CaseCmp("LISTMODS") == 0) || (sCommand.CaseCmp("LISTMODULES") == 0)) { + } else if (sCommand.Equals("LISTMODS") || sCommand.Equals("LISTMODULES")) { #ifdef _MODULES if (m_pUser->IsAdmin()) { CModules& GModules = CZNC::Get().GetModules(); @@ -564,7 +563,7 @@ PutStatus("Modules are not enabled."); #endif return; - } else if ((sCommand.CaseCmp("LISTAVAILMODS") == 0) || (sCommand.CaseCmp("LISTAVAILABLEMODULES") == 0)) { + } else if (sCommand.Equals("LISTAVAILMODS") || sCommand.Equals("LISTAVAILABLEMODULES")) { #ifdef _MODULES if (m_pUser->DenyLoadMod()) { PutStatus("Access Denied."); @@ -620,12 +619,12 @@ PutStatus("Modules are not enabled."); #endif return; - } else if ((sCommand.CaseCmp("LOADMOD") == 0) || (sCommand.CaseCmp("LOADMODULE") == 0)) { + } else if (sCommand.Equals("LOADMOD") || sCommand.Equals("LOADMODULE")) { CString sMod; CString sArgs; bool bGlobal = false; - if (sLine.Token(1).CaseCmp("-global") == 0) { + if (sLine.Token(1).Equals("-global")) { sMod = sLine.Token(2); if (!m_pUser->IsAdmin()) { @@ -668,11 +667,11 @@ PutStatus("Unable to load [" + sMod + "] Modules are not enabled."); #endif return; - } else if ((sCommand.CaseCmp("UNLOADMOD") == 0) || (sCommand.CaseCmp("UNLOADMODULE") == 0)) { + } else if (sCommand.Equals("UNLOADMOD") || sCommand.Equals("UNLOADMODULE")) { CString sMod; bool bGlobal = false; - if (sLine.Token(1).CaseCmp("-global") == 0) { + if (sLine.Token(1).Equals("-global")) { sMod = sLine.Token(2); if (!m_pUser->IsAdmin()) { @@ -707,12 +706,12 @@ PutStatus("Unable to unload [" + sMod + "] Modules are not enabled."); #endif return; - } else if ((sCommand.CaseCmp("RELOADMOD") == 0) || (sCommand.CaseCmp("RELOADMODULE") == 0)) { + } else if (sCommand.Equals("RELOADMOD") || sCommand.Equals("RELOADMODULE")) { CString sMod; CString sArgs; bool bGlobal = false; - if (sLine.Token(1).CaseCmp("-global") == 0) { + if (sLine.Token(1).Equals("-global")) { sMod = sLine.Token(2); if (!m_pUser->IsAdmin()) { @@ -750,7 +749,7 @@ PutStatus("Unable to unload [" + sMod + "] Modules are not enabled."); #endif return; - } else if (sCommand.CaseCmp("SETVHOST") == 0 && (m_pUser->IsAdmin() || !m_pUser->DenySetVHost())) { + } else if (sCommand.Equals("SETVHOST") && (m_pUser->IsAdmin() || !m_pUser->DenySetVHost())) { CString sVHost = sLine.Token(1); if (sVHost.empty()) { @@ -760,10 +759,10 @@ m_pUser->SetVHost(sVHost); PutStatus("Set VHost to [" + m_pUser->GetVHost() + "]"); - } else if (sCommand.CaseCmp("CLEARVHOST") == 0 && (m_pUser->IsAdmin() || !m_pUser->DenySetVHost())) { + } else if (sCommand.Equals("CLEARVHOST") && (m_pUser->IsAdmin() || !m_pUser->DenySetVHost())) { m_pUser->SetVHost(""); PutStatus("VHost Cleared"); - } else if (sCommand.CaseCmp("PLAYBUFFER") == 0) { + } else if (sCommand.Equals("PLAYBUFFER")) { CString sChan = sLine.Token(1); if (sChan.empty()) { @@ -789,7 +788,7 @@ } pChan->SendBuffer(this); - } else if (sCommand.CaseCmp("CLEARBUFFER") == 0) { + } else if (sCommand.Equals("CLEARBUFFER")) { CString sChan = sLine.Token(1); if (sChan.empty()) { @@ -811,7 +810,7 @@ pChan->ClearBuffer(); PutStatus("The buffer for [" + sChan + "] has been cleared"); - } else if (sCommand.CaseCmp("CLEARALLCHANNELBUFFERS") == 0) { + } else if (sCommand.Equals("CLEARALLCHANNELBUFFERS")) { vector<CChan*>::const_iterator it; const vector<CChan*>& vChans = m_pUser->GetChans(); @@ -819,7 +818,7 @@ (*it)->ClearBuffer(); } PutStatus("All channel buffers have been cleared"); - } else if (sCommand.CaseCmp("SETBUFFER") == 0) { + } else if (sCommand.Equals("SETBUFFER")) { CString sChan = sLine.Token(1); if (sChan.empty()) { @@ -849,7 +848,7 @@ pChan->SetBufferCount(uLineCount); PutStatus("BufferCount for [" + sChan + "] set to [" + CString(pChan->GetBufferCount()) + "]"); - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("TRAFFIC") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("TRAFFIC")) { CZNC::Get().UpdateTrafficStats(); const map<CString, CUser*>& msUsers = CZNC::Get().GetUserMap(); CTable Table; @@ -887,7 +886,7 @@ Table.SetCell("Total", CString::ToByteStr(users_total_in + CZNC::Get().BytesRead() + users_total_out + CZNC::Get().BytesWritten())); PutStatus(Table); - } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("UPTIME") == 0) { + } else if (m_pUser->IsAdmin() && sCommand.Equals("UPTIME")) { PutStatus("Running for " + CZNC::Get().GetUptime()); } else { PutStatus("Unknown command [" + sCommand + "] try 'Help'"); Modified: trunk/HTTPSock.cpp =================================================================== --- trunk/HTTPSock.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/HTTPSock.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -65,21 +65,21 @@ CString sName = sLine.Token(0); - if (sName.CaseCmp("GET") == 0) { + if (sName.Equals("GET")) { m_bPost = false; m_sURI = sLine.Token(1); ParseURI(); - } else if (sName.CaseCmp("POST") == 0) { + } else if (sName.Equals("POST")) { m_bPost = true; m_sURI = sLine.Token(1); ParseURI(); - } else if (sName.CaseCmp("Authorization:") == 0) { + } else if (sName.Equals("Authorization:")) { CString sUnhashed; sLine.Token(2).Base64Decode(sUnhashed); m_sUser = sUnhashed.Token(0, false, ":"); m_sPass = sUnhashed.Token(1, true, ":"); m_bLoggedIn = OnLogin(m_sUser, m_sPass); - } else if (sName.CaseCmp("Content-Length:") == 0) { + } else if (sName.Equals("Content-Length:")) { m_uPostLen = sLine.Token(1).ToULong(); } else if (sLine.empty()) { m_bGotHeader = true; @@ -136,21 +136,21 @@ } if (sContentType.empty()) { - if (sFileName.Right(5).CaseCmp(".html") == 0 || sFileName.Right(4).CaseCmp(".htm") == 0) { + if (sFileName.Right(5).Equals(".html") || sFileName.Right(4).Equals(".htm")) { sContentType = "text/html"; - } else if (sFileName.Right(4).CaseCmp(".css") == 0) { + } else if (sFileName.Right(4).Equals(".css")) { sContentType = "text/css"; - } else if (sFileName.Right(3).CaseCmp(".js") == 0) { + } else if (sFileName.Right(3).Equals(".js")) { sContentType = "application/x-javascript"; - } else if (sFileName.Right(4).CaseCmp(".jpg") == 0) { + } else if (sFileName.Right(4).Equals(".jpg")) { sContentType = "image/jpeg"; - } else if (sFileName.Right(4).CaseCmp(".gif") == 0) { + } else if (sFileName.Right(4).Equals(".gif")) { sContentType = "image/gif"; - } else if (sFileName.Right(4).CaseCmp(".ico") == 0) { + } else if (sFileName.Right(4).Equals(".ico")) { sContentType = "image/x-icon"; - } else if (sFileName.Right(4).CaseCmp(".png") == 0) { + } else if (sFileName.Right(4).Equals(".png")) { sContentType = "image/png"; - } else if (sFileName.Right(4).CaseCmp(".bmp") == 0) { + } else if (sFileName.Right(4).Equals(".bmp")) { sContentType = "image/bmp"; } else { sContentType = "text/plain"; Modified: trunk/IRCSock.cpp =================================================================== --- trunk/IRCSock.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/IRCSock.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -79,9 +79,9 @@ MODULECALL(OnRaw(sLine), m_pUser, NULL, return); - if (strncasecmp(sLine.c_str(), "PING ", 5) == 0) { + if (sLine.Equals("PING ", false, 5)) { PutIRC("PONG " + sLine.substr(5)); - } else if (strncasecmp(sLine.c_str(), "ERROR ", 6) == 0) { + } else if (sLine.Equals("ERROR ", false, 6)) { //ERROR :Closing Link: nick[24.24.24.24] (Excess Flood) CString sError(sLine.substr(7)); @@ -114,7 +114,7 @@ CClient* pClient = vClients[a]; CString sClientNick = pClient->GetNick(false); - if (sClientNick.CaseCmp(sNick) != 0) { + if (!sClientNick.Equals(sNick)) { // If they connected with a nick that doesn't match the one we got on irc, then we need to update them pClient->PutClient(":" + sClientNick + "!" + m_Nick.GetIdent() + "@" + m_Nick.GetHost() + " NICK :" + sNick); } @@ -240,7 +240,7 @@ sServer.LeftChomp(); - if (sNick.CaseCmp(GetNick()) == 0) { + if (sNick.Equals(GetNick())) { m_Nick.SetIdent(sIdent); m_Nick.SetHost(sHost); } @@ -326,7 +326,7 @@ sCmd = sLine.Token(1); CString sRest = sLine.Token(2, true); - if (sCmd.CaseCmp("NICK") == 0) { + if (sCmd.Equals("NICK")) { CString sNewNick = sRest; bool bIsVisible = false; @@ -350,7 +350,7 @@ } // Todo: use nick compare function here - if (Nick.GetNick().CaseCmp(GetNick()) == 0) { + if (Nick.GetNick().Equals(GetNick())) { // We are changing our own nick, the clients always must see this! bIsVisible = true; SetNick(sNewNick); @@ -361,7 +361,7 @@ if (!bIsVisible) { return; } - } else if (sCmd.CaseCmp("QUIT") == 0) { + } else if (sCmd.Equals("QUIT")) { CString sMessage = sRest; bool bIsVisible = false; @@ -371,7 +371,7 @@ // :nick!id...@ho... QUIT :message - if (Nick.GetNick().CaseCmp(GetNick()) == 0) { + if (Nick.GetNick().Equals(GetNick())) { m_pUser->PutStatus("You quit [" + sMessage + "]"); } @@ -395,7 +395,7 @@ if (!bIsVisible) { return; } - } else if (sCmd.CaseCmp("JOIN") == 0) { + } else if (sCmd.Equals("JOIN")) { CString sChan = sRest.Token(0); if (sChan.Left(1) == ":") { sChan.LeftChomp(); @@ -404,7 +404,7 @@ CChan* pChan; // Todo: use nick compare function - if (Nick.GetNick().CaseCmp(GetNick()) == 0) { + if (Nick.GetNick().Equals(GetNick())) { m_pUser->AddChan(sChan, false); pChan = m_pUser->FindChan(sChan); if (pChan) { @@ -426,7 +426,7 @@ return; } } - } else if (sCmd.CaseCmp("PART") == 0) { + } else if (sCmd.Equals("PART")) { CString sChan = sRest.Token(0); if (sChan.Left(1) == ":") { sChan.LeftChomp(); @@ -443,7 +443,7 @@ } // Todo: use nick compare function - if (Nick.GetNick().CaseCmp(GetNick()) == 0) { + if (Nick.GetNick().Equals(GetNick())) { m_pUser->DelChan(sChan); } @@ -456,7 +456,7 @@ if (bDetached) { return; } - } else if (sCmd.CaseCmp("MODE") == 0) { + } else if (sCmd.Equals("MODE")) { CString sTarget = sRest.Token(0); CString sModes = sRest.Token(1, true); if (sModes.Left(1) == ":") @@ -492,7 +492,7 @@ } } } - } else if (sCmd.CaseCmp("KICK") == 0) { + } else if (sCmd.Equals("KICK")) { // :opnick!id...@ho... KICK #chan nick :msg CString sChan = sRest.Token(0); CString sKickedNick = sRest.Token(1); @@ -506,7 +506,7 @@ MODULECALL(OnKick(Nick.GetNickMask(), sKickedNick, *pChan, sMsg), m_pUser, NULL, ); } - if (GetNick().CaseCmp(sKickedNick) == 0 && pChan) { + if (GetNick().Equals(sKickedNick) && pChan) { pChan->SetIsOn(false); // Don't try to rejoin! @@ -516,7 +516,7 @@ if ((pChan) && (pChan->IsDetached())) { return; } - } else if (sCmd.CaseCmp("NOTICE") == 0) { + } else if (sCmd.Equals("NOTICE")) { // :nick!id...@ho... NOTICE #chan :Message CString sTarget = sRest.Token(0); CString sMsg = sRest.Token(1, true); @@ -526,7 +526,7 @@ sMsg.LeftChomp(); sMsg.RightChomp(); - if (sTarget.CaseCmp(GetNick()) == 0) { + if (sTarget.Equals(GetNick())) { if (OnCTCPReply(Nick, sMsg)) { return; } @@ -535,7 +535,7 @@ m_pUser->PutUser(":" + Nick.GetNickMask() + " NOTICE " + sTarget + " :\001" + sMsg + "\001"); return; } else { - if (sTarget.CaseCmp(GetNick()) == 0) { + if (sTarget.Equals(GetNick())) { if (OnPrivNotice(Nick, sMsg)) { return; } @@ -546,14 +546,14 @@ } } - if (Nick.GetNick().CaseCmp(m_pUser->GetIRCServer()) == 0) { + if (Nick.GetNick().Equals(m_pUser->GetIRCServer())) { m_pUser->PutUser(":" + Nick.GetNick() + " NOTICE " + sTarget + " :" + sMsg); } else { m_pUser->PutUser(":" + Nick.GetNickMask() + " NOTICE " + sTarget + " :" + sMsg); } return; - } else if (sCmd.CaseCmp("TOPIC") == 0) { + } else if (sCmd.Equals("TOPIC")) { // :nick!id...@ho... TOPIC #chan :This is a topic CChan* pChan = m_pUser->FindChan(sLine.Token(2)); @@ -573,7 +573,7 @@ sLine = ":" + Nick.GetNickMask() + " TOPIC " + pChan->GetName() + " :" + sTopic; } - } else if (sCmd.CaseCmp("PRIVMSG") == 0) { + } else if (sCmd.Equals("PRIVMSG")) { // :nick!id...@ho... PRIVMSG #chan :Message CString sTarget = sRest.Token(0); CString sMsg = sRest.Token(1, true); @@ -586,7 +586,7 @@ sMsg.LeftChomp(); sMsg.RightChomp(); - if (sTarget.CaseCmp(GetNick()) == 0) { + if (sTarget.Equals(GetNick())) { if (OnPrivCTCP(Nick, sMsg)) { return; } @@ -599,7 +599,7 @@ m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + sTarget + " :\001" + sMsg + "\001"); return; } else { - if (sTarget.CaseCmp(GetNick()) == 0) { + if (sTarget.Equals(GetNick())) { if (OnPrivMsg(Nick, sMsg)) { return; } @@ -612,7 +612,7 @@ m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + sTarget + " :" + sMsg); return; } - } else if (sCmd.CaseCmp("WALLOPS") == 0) { + } else if (sCmd.Equals("WALLOPS")) { // :blub!dummy@rox-8DBEFE92 WALLOPS :this is a test CString sMsg = sRest.Token(0, true); @@ -635,14 +635,13 @@ } bool CIRCSock::OnPrivCTCP(CNick& Nick, CString& sMessage) { - if (sMessage.Left(7).CaseCmp("ACTION ") == 0) { - sMessage = sMessage.substr(7); + if (sMessage.TrimPrefix("ACTION ")) { MODULECALL(OnPrivAction(Nick, sMessage), m_pUser, NULL, return true); sMessage = "ACTION " + sMessage; } MODULECALL(OnPrivCTCP(Nick, sMessage), m_pUser, NULL, return true); - if (strncasecmp(sMessage.c_str(), "DCC ", 4) == 0 && m_pUser && m_pUser->BounceDCCs() && m_pUser->IsUserAttached()) { + if (sMessage.Equals("DCC ", false, 4) && m_pUser && m_pUser->BounceDCCs() && m_pUser->IsUserAttached()) { // DCC CHAT chat 2453612361 44592 CString sType = sMessage.Token(1); CString sFile = sMessage.Token(2); @@ -650,33 +649,33 @@ unsigned short uPort = strtoul(sMessage.Token(4).c_str(), NULL, 10); unsigned long uFileSize = strtoul(sMessage.Token(5).c_str(), NULL, 10); - if (sType.CaseCmp("CHAT") == 0) { + if (sType.Equals("CHAT")) { CNick FromNick(Nick.GetNickMask()); unsigned short uBNCPort = CDCCBounce::DCCRequest(FromNick.GetNick(), uLongIP, uPort, "", true, m_pUser, GetLocalIP(), CUtils::GetIP(uLongIP)); if (uBNCPort) { m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(GetLocalIP())) + " " + CString(uBNCPort) + "\001"); } - } else if (sType.CaseCmp("SEND") == 0) { + } else if (sType.Equals("SEND")) { // DCC SEND readme.txt 403120438 5550 1104 unsigned short uBNCPort = CDCCBounce::DCCRequest(Nick.GetNick(), uLongIP, uPort, sFile, false, m_pUser, GetLocalIP(), CUtils::GetIP(uLongIP)); if (uBNCPort) { m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(GetLocalIP())) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001"); } - } else if (sType.CaseCmp("RESUME") == 0) { + } else if (sType.Equals("RESUME")) { // Need to lookup the connection by port, filter the port, and forward to the user CDCCBounce* pSock = (CDCCBounce*) CZNC::Get().GetManager().FindSockByLocalPort(sMessage.Token(3).ToUShort()); - if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) { + if (pSock && pSock->GetSockName().Equals("DCC::", false, 5)) { m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001"); } - } else if (sType.CaseCmp("ACCEPT") == 0) { + } else if (sType.Equals("ACCEPT")) { // Need to lookup the connection by port, filter the port, and forward to the user CSockManager& Manager = CZNC::Get().GetManager(); for (unsigned int a = 0; a < Manager.size(); a++) { CDCCBounce* pSock = (CDCCBounce*) Manager[a]; - if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) { + if (pSock && pSock->GetSockName().Equals("DCC::", false, 5)) { if (pSock->GetUserPort() == atoi(sMessage.Token(3).c_str())) { m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001"); } @@ -750,8 +749,7 @@ CChan* pChan = m_pUser->FindChan(sChan); if (pChan) { // Record a /me - if (sMessage.Left(7).CaseCmp("ACTION ") == 0) { - sMessage = sMessage.substr(7); + if (sMessage.TrimPrefix("ACTION ")) { if (pChan->KeepBuffer() || !m_pUser->IsUserAttached()) { pChan->AddBuffer(":" + Nick.GetNickMask() + " PRIVMSG " + sChan + " :\001ACTION " + m_pUser->AddTimestamp(sMessage) + "\001"); } @@ -895,7 +893,7 @@ CString sName = sArg.Token(0, false, "="); CString sValue = sArg.Token(1, true, "="); - if (sName.CaseCmp("PREFIX") == 0) { + if (sName.Equals("PREFIX")) { CString sPrefixes = sValue.Token(1, false, ")"); CString sPermModes = sValue.Token(0, false, ")"); sPermModes.TrimLeft("("); @@ -904,15 +902,15 @@ m_sPerms = sPrefixes; m_sPermModes = sPermModes; } - } else if (sName.CaseCmp("CHANTYPES") == 0) { + } else if (sName.Equals("CHANTYPES")) { m_pUser->SetChanPrefixes(sValue); - } else if (sName.CaseCmp("NICKLEN") == 0) { + } else if (sName.Equals("NICKLEN")) { unsigned int uMax = sValue.ToUInt(); if (uMax) { m_uMaxNickLen = uMax; } - } else if (sName.CaseCmp("CHANMODES") == 0) { + } else if (sName.Equals("CHANMODES")) { if (!sValue.empty()) { m_mueChanModes.clear(); @@ -924,10 +922,10 @@ } } } - } else if (sName.CaseCmp("NAMESX") == 0) { + } else if (sName.Equals("NAMESX")) { m_bNamesx = true; PutIRC("PROTOCTL NAMESX"); - } else if (sName.CaseCmp("UHNAMES") == 0) { + } else if (sName.Equals("UHNAMES")) { m_bUHNames = true; PutIRC("PROTOCTL UHNAMES"); } @@ -986,19 +984,19 @@ const CString& sConfNick = m_pUser->GetNick().Left(uMax); const CString& sAltNick = m_pUser->GetAltNick().Left(uMax); - if (sBadNick.CaseCmp(sConfNick) == 0) { - if ((!sAltNick.empty()) && (sConfNick.CaseCmp(sAltNick) != 0)) { + if (sBadNick.Equals(sConfNick)) { + if ((!sAltNick.empty()) && (!sConfNick.Equals(sAltNick))) { PutIRC("NICK " + sAltNick); } else { PutIRC("NICK " + sConfNick.Left(uMax -1) + "-"); } - } else if (sBadNick.CaseCmp(sAltNick) == 0) { + } else if (sBadNick.Equals(sAltNick)) { PutIRC("NICK " + sConfNick.Left(uMax -1) + "-"); - } else if (sBadNick.CaseCmp(CString(sConfNick.Left(uMax -1) + "-")) == 0) { + } else if (sBadNick.Equals(CString(sConfNick.Left(uMax -1) + "-"))) { PutIRC("NICK " + sConfNick.Left(uMax -1) + "|"); - } else if (sBadNick.CaseCmp(CString(sConfNick.Left(uMax -1) + "|")) == 0) { + } else if (sBadNick.Equals(CString(sConfNick.Left(uMax -1) + "|"))) { PutIRC("NICK " + sConfNick.Left(uMax -1) + "^"); - } else if (sBadNick.CaseCmp(CString(sConfNick.Left(uMax -1) + "^")) == 0) { + } else if (sBadNick.Equals(CString(sConfNick.Left(uMax -1) + "^"))) { PutIRC("NICK " + sConfNick.Left(uMax -1) + "a"); } else { char cLetter = 0; Modified: trunk/Modules.cpp =================================================================== --- trunk/Modules.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/Modules.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -290,7 +290,7 @@ for (unsigned int a = 0; a < m_vTimers.size(); a++) { CTimer* pTimer = m_vTimers[a]; - if (pTimer->GetName().CaseCmp(sLabel) == 0) { + if (pTimer->GetName().Equals(sLabel)) { m_vTimers.erase(m_vTimers.begin() +a); m_pManager->DelCronByAddr(pTimer); return true; @@ -314,7 +314,7 @@ CTimer* CModule::FindTimer(const CString& sLabel) { for (unsigned int a = 0; a < m_vTimers.size(); a++) { CTimer* pTimer = m_vTimers[a]; - if (pTimer->GetName().CaseCmp(sLabel) == 0) { + if (pTimer->GetName().Equals(sLabel)) { return pTimer; } } @@ -373,7 +373,7 @@ for (unsigned int a = 0; a < m_vSockets.size(); a++) { CSocket* pSocket = m_vSockets[a]; - if (pSocket->GetSockName().CaseCmp(sSockName) == 0) { + if (pSocket->GetSockName().Equals(sSockName)) { m_vSockets.erase(m_vSockets.begin() +a); m_pManager->DelSockByAddr(pSocket); return true; @@ -397,7 +397,7 @@ CSocket* CModule::FindSocket(const CString& sSockName) { for (unsigned int a = 0; a < m_vSockets.size(); a++) { CSocket* pSocket = m_vSockets[a]; - if (pSocket->GetSockName().CaseCmp(sSockName) == 0) { + if (pSocket->GetSockName().Equals(sSockName)) { return pSocket; } } @@ -639,7 +639,7 @@ CModule* CModules::FindModule(const CString& sModule) const { for (unsigned int a = 0; a < size(); a++) { - if (sModule.CaseCmp((*this)[a]->GetModName()) == 0) { + if (sModule.Equals((*this)[a]->GetModName())) { return (*this)[a]; } } Modified: trunk/Nick.cpp =================================================================== --- trunk/Nick.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/Nick.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -65,7 +65,7 @@ const map<CString,CNick*>& msNicks = pChan->GetNicks(); for (map<CString,CNick*>::const_iterator it = msNicks.begin(); it != msNicks.end(); it++) { - if (it->first.CaseCmp(m_sNick) == 0) { + if (it->first.Equals(m_sNick)) { vRetChans.push_back(pChan); continue; } Modified: trunk/Template.cpp =================================================================== --- trunk/Template.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/Template.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -38,21 +38,21 @@ return ""; } - if (sName.CaseCmp("__ID__") == 0) { + if (sName.Equals("__ID__")) { return CString(GetRowIndex() +1); - } else if (sName.CaseCmp("__COUNT__") == 0) { + } else if (sName.Equals("__COUNT__")) { return CString(GetRowCount()); - } else if (sName.CaseCmp("__ODD__") == 0) { + } else if (sName.Equals("__ODD__")) { return ((GetRowIndex() %2) ? "" : "1"); - } else if (sName.CaseCmp("__EVEN__") == 0) { + } else if (sName.Equals("__EVEN__")) { return ((GetRowIndex() %2) ? "1" : ""); - } else if (sName.CaseCmp("__FIRST__") == 0) { + } else if (sName.Equals("__FIRST__")) { return ((GetRowIndex() == 0) ? "1" : ""); - } else if (sName.CaseCmp("__LAST__") == 0) { + } else if (sName.Equals("__LAST__")) { return ((GetRowIndex() == m_pvRows->size() -1) ? "1" : ""); - } else if (sName.CaseCmp("__OUTER__") == 0) { + } else if (sName.Equals("__OUTER__")) { return ((GetRowIndex() == 0 || GetRowIndex() == m_pvRows->size() -1) ? "1" : ""); - } else if (sName.CaseCmp("__INNER__") == 0) { + } else if (sName.Equals("__INNER__")) { return ((GetRowIndex() == 0 || GetRowIndex() == m_pvRows->size() -1) ? "" : "1"); } @@ -185,13 +185,13 @@ CString sArgs = sMid.Token(1, true); if (!uSkip) { - if (sAction.CaseCmp("INC") == 0) { + if (sAction.Equals("INC")) { if (!Print(File.GetDir() + sArgs, oOut)) { return false; } - } else if (sAction.CaseCmp("SETOPTION") == 0) { + } else if (sAction.Equals("SETOPTION")) { m_spOptions->Parse(sArgs); - } else if (sAction.CaseCmp("ADDROW") == 0) { + } else if (sAction.Equals("ADDROW")) { CString sLoopName = sArgs.Token(0); MCString msRow; @@ -202,12 +202,12 @@ NewRow[it->first] = it->second; } } - } else if (sAction.CaseCmp("SET") == 0) { + } else if (sAction.Equals("SET")) { CString sName = sArgs.Token(0); CString sValue = sArgs.Token(1, true); (*this)[sName] = sValue; - } else if (sAction.CaseCmp("JOIN") == 0) { + } else if (sAction.Equals("JOIN")) { VCString vsArgs; sArgs.Split(" ", vsArgs, false, "\"", "\""); @@ -219,7 +219,7 @@ for (unsigned int a = 1; a < vsArgs.size(); a++) { const CString& sArg = vsArgs[a]; - if (sArg.Left(4).CaseCmp("ESC=") == 0) { + if (sArg.Equals("ESC=", false, 4)) { eEscape = CString::ToEscape(sArg.LeftChomp_n(4)); } else { CString sValue = GetValue(sArg); @@ -235,9 +235,9 @@ } } } - } else if (sAction.CaseCmp("VAR") == 0) { + } else if (sAction.Equals("VAR")) { sOutput += GetValue(sArgs); - } else if (sAction.CaseCmp("LOOP") == 0) { + } else if (sAction.Equals("LOOP")) { CTemplateLoopContext* pContext = GetCurLoopContext(); if (!pContext || pContext->GetFilePosition() != uCurPos) { @@ -253,7 +253,7 @@ uSkip++; } } - } else if (sAction.CaseCmp("IF") == 0) { + } else if (sAction.Equals("IF")) { if (ValidIf(sArgs)) { uNestedIfs++; bValidLastIf = true; @@ -262,19 +262,19 @@ bValidLastIf = false; } } - } else if (sAction.CaseCmp("IF") == 0) { + } else if (sAction.Equals("IF")) { uSkip++; - } else if (sAction.CaseCmp("LOOP") == 0) { + } else if (sAction.Equals("LOOP")) { uSkip++; } - if (sAction.CaseCmp("ENDIF") == 0) { + if (sAction.Equals("ENDIF")) { if (uSkip) { uSkip--; } else { uNestedIfs--; } - } else if (sAction.CaseCmp("ENDLOOP") == 0) { + } else if (sAction.Equals("ENDLOOP")) { if (uSkip) { uSkip--; } else { @@ -296,11 +296,11 @@ } } } - } else if (sAction.CaseCmp("ELSE") == 0) { + } else if (sAction.Equals("ELSE")) { if (!bValidLastIf && uSkip == 1) { CString sArg = sArgs.Token(0); - if (sArg.empty() || (sArg.CaseCmp("IF") == 0 && ValidIf(sArgs.Token(1, true)))) { + if (sArg.empty() || (sArg.Equals("IF") && ValidIf(sArgs.Token(1, true)))) { uSkip = 0; bValidLastIf = true; } @@ -413,7 +413,7 @@ return (bNegate != IsTrue(sName)); } - return (bNegate != (GetValue(sName).CaseCmp(sValue) == 0)); + return (bNegate != GetValue(sName).Equals(sValue)); } bool CTemplate::IsTrue(const CString& sName) { Modified: trunk/User.cpp =================================================================== --- trunk/User.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/User.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -368,7 +368,7 @@ } for (a = 0; a < m_vServers.size(); a++) { - if (sServer.CaseCmp(m_vServers[a]->GetName()) == 0) { + if (sServer.Equals(m_vServers[a]->GetName())) { m_uServerIdx = a +1; break; } @@ -513,7 +513,7 @@ } for (unsigned int a = 0; a < m_vChans.size(); a++) { - if (m_vChans[a]->GetName().CaseCmp(pChan->GetName()) == 0) { + if (m_vChans[a]->GetName().Equals(pChan->GetName())) { delete pChan; return false; } @@ -535,7 +535,7 @@ bool CUser::DelChan(const CString& sName) { for (vector<CChan*>::iterator a = m_vChans.begin(); a != m_vChans.end(); a++) { - if (sName.CaseCmp((*a)->GetName()) == 0) { + if (sName.Equals((*a)->GetName())) { delete *a; m_vChans.erase(a); return true; @@ -651,7 +651,7 @@ CChan* CUser::FindChan(const CString& sName) const { for (unsigned int a = 0; a < m_vChans.size(); a++) { CChan* pChan = m_vChans[a]; - if (sName.CaseCmp(pChan->GetName()) == 0) { + if (sName.Equals(pChan->GetName())) { return pChan; } } @@ -682,7 +682,7 @@ CServer* CUser::FindServer(const CString& sName) const { for (unsigned int a = 0; a < m_vServers.size(); a++) { CServer* pServer = m_vServers[a]; - if (sName.CaseCmp(pServer->GetName()) == 0) { + if (sName.Equals(pServer->GetName())) { return pServer; } } @@ -700,7 +700,7 @@ for (vector<CServer*>::iterator it = m_vServers.begin(); it != m_vServers.end(); it++, a++) { CServer* pServer = *it; - if (pServer->GetName().CaseCmp(sName) == 0) { + if (pServer->GetName().Equals(sName)) { CServer* pCurServer = GetCurrentServer(); m_vServers.erase(it); @@ -813,7 +813,7 @@ CString sSaltedPass = sPass + m_sPassSalt; - return (m_sPass.CaseCmp(sSaltedPass.MD5()) == 0); + return (m_sPass.Equals(sSaltedPass.MD5())); } /*CClient* CUser::GetClient() { @@ -823,7 +823,7 @@ for (unsigned int a = 0; a < Manager.size(); a++) { Csock* pSock = Manager[a]; - if (pSock->GetSockName().CaseCmp(sSockName) == 0) { + if (pSock->GetSockName().Equals(sSockName)) { if (!pSock->IsClosed()) { return (CClient*) pSock; } @@ -918,7 +918,7 @@ CSockManager& Manager = CZNC::Get().GetManager(); for (unsigned int a = 0; a < Manager.size(); a++) { - if (strncasecmp(Manager[a]->GetSockName().c_str(), "DCC::LISTEN::", 13) == 0) { + if (Manager[a]->GetSockName().Equals("DCC::LISTEN::", false, 13)) { CDCCSock* pSock = (CDCCSock*) Manager[a]; if (pSock->GetLocalPort() == uPort) { @@ -948,7 +948,7 @@ unsigned short uPort = CZNC::Get().GetManager().ListenRand("DCC::LISTEN::" + sRemoteNick, GetLocalIP(), false, SOMAXCONN, pSock, 120); - if (GetNick().CaseCmp(sRemoteNick) == 0) { + if (GetNick().Equals(sRemoteNick)) { PutUser(":" + GetStatusPrefix() + "status!zn...@zn... PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalIP())) + " " + CString(uPort) + " " + CString(pFile->GetSize()) + "\001"); } else { Modified: trunk/Utils.cpp =================================================================== --- trunk/Utils.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/Utils.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -260,9 +260,9 @@ GetInput(sPrompt, sRet, sDefault, "yes/no"); - if (sRet.CaseCmp("yes") == 0) { + if (sRet.Equals("yes")) { return true; - } else if (sRet.CaseCmp("no") == 0) { + } else if (sRet.Equals("no")) { return false; } @@ -403,7 +403,7 @@ bool CTable::AddColumn(const CString& sName) { for (unsigned int a = 0; a < m_vsHeaders.size(); a++) { - if (m_vsHeaders[a].CaseCmp(sName) == 0) { + if (m_vsHeaders[a].Equals(sName)) { return false; } } Modified: trunk/ZNCString.cpp =================================================================== --- trunk/ZNCString.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/ZNCString.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -276,13 +276,13 @@ } CString::EEscape CString::ToEscape(const CString& sEsc) { - if (sEsc.CaseCmp("ASCII") == 0) { + if (sEsc.Equals("ASCII")) { return EASCII; - } else if (sEsc.CaseCmp("HTML") == 0) { + } else if (sEsc.Equals("HTML")) { return EHTML; - } else if (sEsc.CaseCmp("URL") == 0) { + } else if (sEsc.Equals("URL")) { return EURL; - } else if (sEsc.CaseCmp("SQL") == 0) { + } else if (sEsc.Equals("SQL")) { return ESQL; } @@ -919,7 +919,7 @@ return sRet.RightChomp_n(); } -bool CString::ToBool() const { return (!Trim_n().Trim_n("0").empty() && Trim_n().CaseCmp("false") != 0); } +bool CString::ToBool() const { return (!Trim_n().Trim_n("0").empty() && !Trim_n().Equals("false")); } short CString::ToShort() const { return strtoul(this->c_str(), (char**) NULL, 10); } unsigned short CString::ToUShort() const { return strtoul(this->c_str(), (char**) NULL, 10); } unsigned int CString::ToUInt() const { return strtoul(this->c_str(), (char**) NULL, 10); } @@ -976,7 +976,7 @@ } bool CString::TrimPrefix(const CString& sPrefix) { - if (CaseCmp(sPrefix, sPrefix.length()) == 0) { + if (Equals(sPrefix, false, sPrefix.length())) { LeftChomp(sPrefix.length()); return true; } else { @@ -985,7 +985,7 @@ } bool CString::TrimSuffix(const CString& sSuffix) { - if (Right(sSuffix.length()).CaseCmp(sSuffix) == 0) { + if (Right(sSuffix.length()).Equals(sSuffix)) { RightChomp(sSuffix.length()); return true; } else { Modified: trunk/modules/autoattach.cpp =================================================================== --- trunk/modules/autoattach.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/modules/autoattach.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -58,7 +58,7 @@ virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0); - if (sCommand.CaseCmp("ADD") == 0) { + if (sCommand.Equals("ADD")) { CString sChan = sLine.Token(1); if (AlreadyAdded(sChan)) { @@ -68,14 +68,14 @@ } else { PutModule("Usage: Add [!]<#chan>"); } - } else if (sCommand.CaseCmp("DEL") == 0) { + } else if (sCommand.Equals("DEL")) { CString sChan = sLine.Token(1); if (Del(sChan)) PutModule("Removed " + sChan + " from list"); else PutModule("Usage: Del [!]<#chan>"); - } else if (sCommand.CaseCmp("LIST") == 0) { + } else if (sCommand.Equals("LIST")) { CTable Table; Table.AddColumn("Chan"); @@ -94,7 +94,7 @@ } else { PutModule("You have no entries."); } - } else if (sCommand.CaseCmp("HELP") == 0) { + } else if (sCommand.Equals("HELP")) { CTable Table; Table.AddColumn("Command"); Table.AddColumn("Description"); Modified: trunk/modules/autocycle.cpp =================================================================== --- trunk/modules/autocycle.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/modules/autocycle.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -42,7 +42,7 @@ virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0); - if (sCommand.CaseCmp("ADD") == 0) { + if (sCommand.Equals("ADD")) { CString sChan = sLine.Token(1); if (AlreadyAdded(sChan)) { @@ -52,14 +52,14 @@ } else { PutModule("Usage: Add [!]<#chan>"); } - } else if (sCommand.CaseCmp("DEL") == 0) { + } else if (sCommand.Equals("DEL")) { CString sChan = sLine.Token(1); if (Del(sChan)) PutModule("Removed " + sChan + " from list"); else PutModule("Usage: Del [!]<#chan>"); - } else if (sCommand.CaseCmp("LIST") == 0) { + } else if (sCommand.Equals("LIST")) { CTable Table; Table.AddColumn("Chan"); @@ -78,7 +78,7 @@ } else { PutModule("You have no entries."); } - } else if (sCommand.CaseCmp("HELP") == 0) { + } else if (sCommand.Equals("HELP")) { CTable Table; Table.AddColumn("Command"); Table.AddColumn("Description"); @@ -127,7 +127,7 @@ // Is that person us and we don't have op? const CNick* pNick = Channel.GetNicks().begin()->second; - if (!pNick->HasPerm(CChan::Op) && pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0) + if (!pNick->HasPerm(CChan::Op) && pNick->GetNick().Equals(m_pUser->GetCurNick())) Channel.Cycle(); } Modified: trunk/modules/autoop.cpp =================================================================== --- trunk/modules/autoop.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/modules/autoop.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -163,7 +163,7 @@ for (map<CString, CAutoOpUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); it++) { // and the nick who joined is a valid user if (it->second->HostMatches(Nick.GetHostMask()) && it->second->ChannelMatches(Channel.GetName())) { - if (it->second->GetUserKey().CaseCmp("__NOKEY__") == 0) { + if (it->second->GetUserKey().Equals("__NOKEY__")) { PutIRC("MODE " + Channel.GetName() + " +o " + Nick.GetNick()); } else { // then insert this nick into the queue, the timer does the rest @@ -195,15 +195,15 @@ } virtual EModRet OnPrivNotice(CNick& Nick, CString& sMessage) { - if (sMessage.Token(0).CaseCmp("!ZNCAO") != 0) { + if (!sMessage.Token(0).Equals("!ZNCAO")) { return CONTINUE; } CString sCommand = sMessage.Token(1); - if (sCommand.CaseCmp("CHALLENGE") == 0) { + if (sCommand.Equals("CHALLENGE")) { ChallengeRespond(Nick, sMessage.Token(2)); - } else if (sCommand.CaseCmp("RESPONSE") == 0) { + } else if (sCommand.Equals("RESPONSE")) { VerifyResponse(Nick, sMessage.Token(2)); } @@ -213,16 +213,16 @@ virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0).AsUpper(); - if (sCommand.CaseCmp("HELP") == 0) { + if (sCommand.Equals("HELP")) { PutModule("Commands are: ListUsers, AddChans, DelChans, AddUser, DelUser"); - } else if (sCommand.CaseCmp("TIMERS") == 0) { + } else if (sCommand.Equals("TIMERS")) { ListTimers(); - } else if (sCommand.CaseCmp("ADDUSER") == 0 || sCommand.CaseCmp("DELUSER") == 0) { + } else if (sCommand.Equals("ADDUSER") || sCommand.Equals("DELUSER")) { CString sUser = sLine.Token(1); CString sHost = sLine.Token(2); CString sKey = sLine.Token(3); - if (sCommand.CaseCmp("ADDUSER") == 0) { + if (sCommand.Equals("ADDUSER")) { if (sHost.empty()) { PutModule("Usage: " + sCommand + " <user> <hostmask> <key> [channels]"); } else { @@ -236,7 +236,7 @@ DelUser(sUser); DelNV(sUser); } - } else if (sCommand.CaseCmp("LISTUSERS") == 0) { + } else if (sCommand.Equals("LISTUSERS")) { if (m_msUsers.empty()) { PutModule("There are no users defined"); return; @@ -258,7 +258,7 @@ } PutModule(Table); - } else if (sCommand.CaseCmp("ADDCHANS") == 0 || sCommand.CaseCmp("DELCHANS") == 0) { + } else if (sCommand.Equals("ADDCHANS") || sCommand.Equals("DELCHANS")) { CString sUser = sLine.Token(1); CString sChans = sLine.Token(2, true); @@ -274,7 +274,7 @@ return; } - if (sCommand.CaseCmp("ADDCHANS") == 0) { + if (sCommand.Equals("ADDCHANS")) { pUser->AddChans(sChans); PutModule("Channel(s) added to user [" + pUser->GetUsername() + "]"); } else { Modified: trunk/modules/awaynick.cpp =================================================================== --- trunk/modules/awaynick.cpp 2008-09-30 14:43:51 UTC (rev 1233) +++ trunk/modules/awaynick.cpp 2008-09-30 15:15:59 UTC (rev 1234) @@ -76,7 +76,7 @@ if (pIRCSock) { CString sConfNick = m_pUser->GetNick(); - if (pIRCSock->GetNick().CaseCmp(GetAwayNick().Left(pIRCSock->GetNick().length())) == 0) { + if (pIRCSock->GetNick().Equals(GetAwayNick().Left(pIRCSock->GetNick().length()))) { RemTimer("BackNickTimer"); AddTimer(new CBackNickTimer(*this)); } @@ -104,11 +104,13 @@ } } - virtual void OnModCommand(const CString& sCommand) { - if (strcasecmp(sCommand.c_str(), "TIMERS") == 0) { + virtual void OnModCommand(const CSt... [truncated message content] |