Moved CUtils::wildcmp() into CString class

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@251 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2005-05-08 07:51:46 +00:00
parent 1c5981ee6d
commit 0823b27f37
7 changed files with 10 additions and 50 deletions
+1 -1
View File
@@ -207,7 +207,7 @@ public:
if ((strcmp(de->d_name, ".") == 0) || (strcmp(de->d_name, "..") == 0)) {
continue;
}
if ((!sWildcard.empty()) && (!CUtils::wildcmp(sWildcard.c_str(), de->d_name))) {
if ((!sWildcard.empty()) && (!CString(de->d_name).WildCmp(sWildcard))) {
continue;
}
+3 -3
View File
@@ -59,7 +59,7 @@ void CIRCSock::ReadLine(const CString& sData) {
if (strncasecmp(sLine.c_str(), "PING ", 5) == 0) {
PutServ("PONG " + sLine.substr(5));
} else if (CUtils::wildcmp(":* * *", sLine.c_str())) { //"^:(\\S+) (\\d\\d\\d) (.*?) (.*)$", vCap)) {
} else if (sLine.WildCmp(":* * *")) { //"^:(\\S+) (\\d\\d\\d) (.*?) (.*)$", vCap)) {
CString sCmd = sLine.Token(1);
if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) {
@@ -503,7 +503,7 @@ void CIRCSock::ReadLine(const CString& sData) {
CString sMsg = sRest.Token(1, true);
sMsg.LeftChomp();
if (CUtils::wildcmp("\001*\001", sMsg.c_str())) {
if (sMsg.WildCmp("\001*\001")) {
sMsg.LeftChomp();
sMsg.RightChomp();
@@ -552,7 +552,7 @@ void CIRCSock::ReadLine(const CString& sData) {
sMsg.LeftChomp();
}
if (CUtils::wildcmp("\001*\001", sMsg.c_str())) {
if (sMsg.WildCmp("\001*\001")) {
sMsg.LeftChomp();
sMsg.RightChomp();
+1 -1
View File
@@ -62,7 +62,7 @@ bool CUser::IsHostAllowed(const CString& sHostMask) {
}
for (set<CString>::iterator a = m_ssAllowedHosts.begin(); a != m_ssAllowedHosts.end(); a++) {
if (CUtils::wildcmp(*a, sHostMask)) {
if (sHostMask.WildCmp(*a)) {
return true;
}
}
+3 -3
View File
@@ -147,7 +147,7 @@ void CUserSock::ReadLine(const CString& sData) {
return;
}
if (CUtils::wildcmp("DCC * (*)", sMsg.c_str())) {
if (sMsg.WildCmp("DCC * (*)")) {
sMsg = "DCC " + sLine.Token(3) + " (" + ((m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP()) + ")";
}
@@ -158,7 +158,7 @@ void CUserSock::ReadLine(const CString& sData) {
}
#ifdef _MODULES
if (CUtils::wildcmp("\001*\001", sMsg.c_str())) {
if (sMsg.WildCmp("\001*\001")) {
CString sCTCP = sMsg;
sCTCP.LeftChomp();
sCTCP.RightChomp();
@@ -185,7 +185,7 @@ void CUserSock::ReadLine(const CString& sData) {
sMsg.LeftChomp();
}
if (CUtils::wildcmp("\001*\001", sMsg.c_str())) {
if (sMsg.WildCmp("\001*\001")) {
CString sCTCP = sMsg;
sCTCP.LeftChomp();
sCTCP.RightChomp();
-38
View File
@@ -370,44 +370,6 @@ void CUtils::PrintStatus(bool bSuccess, const CString& sMessage) {
}
}
bool CUtils::wildcmp(const CString& sWild, const CString& sString) {
// Written by Jack Handy - jakkhandy@hotmail.com
const char *wild = sWild.c_str(), *CString = sString.c_str();
const char *cp = NULL, *mp = NULL;
while ((*CString) && (*wild != '*')) {
if ((*wild != *CString) && (*wild != '?')) {
return false;
}
wild++;
CString++;
}
while (*CString) {
if (*wild == '*') {
if (!*++wild) {
return true;
}
mp = wild;
cp = CString+1;
} else if ((*wild == *CString) || (*wild == '?')) {
wild++;
CString++;
} else {
wild = mp;
CString = cp++;
}
}
while (*wild == '*') {
wild++;
}
return (*wild == 0);
}
CTable::CTable() {}
CTable::~CTable() {
for (unsigned int a = 0; a < size(); a++) {
-2
View File
@@ -42,8 +42,6 @@ public:
static bool GetBoolInput(const CString& sPrompt, bool *pbDefault = NULL);
static bool GetNumInput(const CString& sPrompt, unsigned int& uRet, unsigned int uMin = 0, unsigned int uMax = ~0, unsigned int uDefault = ~0);
static bool wildcmp(const CString& sWild, const CString& sString);
static unsigned long long GetMillTime() {
struct timeval tv;
unsigned long long iTime = 0;
+2 -2
View File
@@ -67,7 +67,7 @@ public:
for (unsigned int a = 0; a < m_vsSources.size(); a++) {
const CWatchSource& WatchSource = m_vsSources[a];
if (CUtils::wildcmp(Lower(WatchSource.GetSource()), Lower(sSource))) {
if (sSource.AsLower().WildCmp(Lower(WatchSource.GetSource()))) {
if (WatchSource.IsNegated()) {
return false;
} else {
@@ -77,7 +77,7 @@ public:
}
}
return (bGoodSource && CUtils::wildcmp(Lower(m_sHostMask), Lower(Nick.GetHostMask())) && CUtils::wildcmp(Lower(m_sPattern), Lower(sText)));
return (bGoodSource && Nick.GetHostMask().AsLower().WildCmp(Lower(m_sHostMask))) && sText.AsLower().WildCmp(Lower(m_sPattern));
}
bool operator ==(const CWatchEntry& WatchEntry) {