Use CString::Split() in more places

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1808 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-03-07 11:08:26 +00:00
parent 698965777a
commit 5d9a22f6cc
8 changed files with 48 additions and 51 deletions
+7 -5
View File
@@ -309,14 +309,16 @@ void CClient::ReadLine(const CString& sData) {
Close(Csock::CLT_AFTERWRITE); // 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.Equals("PROTOCTL")) {
unsigned int i = 1;
while (!sLine.Token(i).empty()) {
if (sLine.Token(i).Equals("NAMESX")) {
VCString vsTokens;
VCString::const_iterator it;
sLine.Token(1, true).Split(" ", vsTokens, false);
for (it = vsTokens.begin(); it != vsTokens.end(); ++it) {
if (*it == "NAMESX") {
m_bNamesx = true;
} else if (sLine.Token(i).Equals("UHNAMES")) {
} else if (*it == "UHNAMES") {
m_bUHNames = true;
}
i++;
}
return; // If the server understands it, we already enabled namesx / uhnames
} else if (sCommand.Equals("NOTICE")) {
+6 -4
View File
@@ -1000,10 +1000,13 @@ void CIRCSock::ForwardRaw353(const CString& sLine) const {
// Get everything except the actual user list
CString sTmp = sLine.Token(0, false, " :") + " :";
unsigned int i = 0;
VCString vsNicks;
VCString::const_iterator it;
// This loop runs once for every nick on the channel
for (;;) {
CString sNick = sNicks.Token(i).Trim_n(" ");
sNicks.Split(" ", vsNicks, false);
for (it = vsNicks.begin(); it != vsNicks.end(); ++it) {
CString sNick = *it;
if (sNick.empty())
break;
@@ -1022,7 +1025,6 @@ void CIRCSock::ForwardRaw353(const CString& sLine) const {
}
sTmp += sNick + " ";
i++;
}
// Strip away the spaces we inserted at the end
sTmp.TrimRight(" ");
+5 -7
View File
@@ -17,15 +17,13 @@ public:
}
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
unsigned int a = 0;
CString sChan = sArgs.Token(a++);
VCString vsChans;
sArgs.Split(" ", vsChans, false);
while (!sChan.empty()) {
if (!Add(sChan)) {
PutModule("Unable to add [" + sChan + "]");
for (VCString::const_iterator it = vsChans.begin(); it != vsChans.end(); ++it) {
if (!Add(*it)) {
PutModule("Unable to add [" + *it + "]");
}
sChan = sArgs.Token(a++);
}
// Load our saved settings, ignore errors
+5 -7
View File
@@ -15,15 +15,13 @@ public:
virtual ~CAutoCycleMod() {}
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
unsigned int a = 0;
CString sChan = sArgs.Token(a++);
VCString vsChans;
sArgs.Split(" ", vsChans, false);
while (!sChan.empty()) {
if (!Add(sChan)) {
PutModule("Unable to add [" + sChan + "]");
for (VCString::const_iterator it = vsChans.begin(); it != vsChans.end(); ++it) {
if (!Add(*it)) {
PutModule("Unable to add [" + *it + "]");
}
sChan = sArgs.Token(a++);
}
// Load our saved settings, ignore errors
+4 -5
View File
@@ -109,14 +109,13 @@ public:
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
// Load the chans from the command line
unsigned int a = 0;
CString sChan = sArgs.Token(a++);
VCString vsChans;
sArgs.Split(" ", vsChans, false);
while (!sChan.empty()) {
for (VCString::const_iterator it = vsChans.begin(); it != vsChans.end(); ++it) {
CString sName = "Args";
sName += CString(a);
AddUser(sName, "*", sChan);
sChan = sArgs.Token(a++);
AddUser(sName, "*", *it);
}
// Load the saved users
+7 -7
View File
@@ -27,17 +27,17 @@ public:
}
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
int i(0);
CString arg(sArgs.Token(i));
VCString vsChans;
VCString::const_iterator it;
sArgs.Split(" ", vsChans, false);
while (!arg.empty()) {
if (arg.StrCmp("saslauthd") || arg.StrCmp("auxprop")) {
method += arg + " ";
for (it = vsChans.begin(); it != vsChans.end(); ++it) {
if (it->StrCmp("saslauthd") || it->StrCmp("auxprop")) {
method += *it + " ";
}
else {
CUtils::PrintError("Ignoring invalid SASL pwcheck method: " + arg);
CUtils::PrintError("Ignoring invalid SASL pwcheck method: " + *it);
}
arg = sArgs.Token(++i);
}
method.TrimRight();
+7 -6
View File
@@ -71,12 +71,13 @@ public:
}
}
CString sChan;
unsigned int a = 0;
while (!(sChan = sArgs.Token(a++)).empty()) {
if (sChan.Left(2) == CHAN_PREFIX) {
sChan = sChan.Left(32);
m_ssDefaultChans.insert(sChan);
VCString vsChans;
VCString::const_iterator it;
sArgs.Split(" ", vsChans, false);
for (it = vsChans.begin(); it != vsChans.end(); ++it) {
if (it->Left(2) == CHAN_PREFIX) {
m_ssDefaultChans.insert(it->Left(32));
}
}
+7 -10
View File
@@ -130,21 +130,18 @@ public:
void SetPattern(const CString& s) { m_sPattern = s; }
void SetDisabled(bool b = true) { m_bDisabled = b; }
void SetSources(const CString& sSources) {
unsigned int uIdx = 1;
CString sSrc = sSources.Token(0);
VCString vsSources;
VCString::iterator it;
sSources.Split(" ", vsSources, false);
m_vsSources.clear();
while (sSrc.size()) {
if (sSrc[0] == '!') {
if (sSrc.size() > 1) {
m_vsSources.push_back(CWatchSource(sSrc.substr(1), true));
}
for (it = vsSources.begin(); it != vsSources.end(); ++it) {
if (it->at(0) == '!' && it->size() > 1) {
m_vsSources.push_back(CWatchSource(it->substr(1), true));
} else {
m_vsSources.push_back(CWatchSource(sSrc, false));
m_vsSources.push_back(CWatchSource(*it, false));
}
sSrc = sSources.Token(uIdx++);
}
}
// !Setters