mirror of
https://github.com/znc/znc.git
synced 2026-08-09 18:32:55 +02:00
Removed bad version of WildCmp() and inserted the correct version of wildcmp()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@40 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+4
-4
@@ -62,7 +62,7 @@ void CIRCSock::ReadLine(const string& 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 (CUtils::wildcmp(":* * *", sLine.c_str())) { //"^:(\\S+) (\\d\\d\\d) (.*?) (.*)$", vCap)) {
|
||||
string sCmd = CUtils::Token(sLine, 1);
|
||||
|
||||
if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) {
|
||||
@@ -284,7 +284,7 @@ void CIRCSock::ReadLine(const string& sData) {
|
||||
return; // return so we don't send them the raw twice
|
||||
}
|
||||
}
|
||||
} else { //if (CUtils::WildCmp(":*!*@* * *", sLine.c_str())) {
|
||||
} else { //if (CUtils::wildcmp(":*!*@* * *", sLine.c_str())) {
|
||||
string sNickMask = CUtils::Token(sLine, 0);
|
||||
CUtils::LeftChomp(sNickMask);
|
||||
|
||||
@@ -428,7 +428,7 @@ void CIRCSock::ReadLine(const string& sData) {
|
||||
string sMsg = CUtils::Token(sRest, 1, true);
|
||||
CUtils::LeftChomp(sMsg);
|
||||
|
||||
if (CUtils::WildCmp("\001*\001", sMsg.c_str())) {
|
||||
if (CUtils::wildcmp("\001*\001", sMsg.c_str())) {
|
||||
CUtils::LeftChomp(sMsg);
|
||||
CUtils::RightChomp(sMsg);
|
||||
|
||||
@@ -465,7 +465,7 @@ void CIRCSock::ReadLine(const string& sData) {
|
||||
CUtils::LeftChomp(sMsg);
|
||||
}
|
||||
|
||||
if (CUtils::WildCmp("\001*\001", sMsg.c_str())) {
|
||||
if (CUtils::wildcmp("\001*\001", sMsg.c_str())) {
|
||||
CUtils::LeftChomp(sMsg);
|
||||
CUtils::RightChomp(sMsg);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ bool CUser::AddAllowedHost(const string& sHostMask) {
|
||||
|
||||
bool CUser::IsHostAllowed(const string& sHostMask) {
|
||||
for (set<string>::iterator a = m_ssAllowedHosts.begin(); a != m_ssAllowedHosts.end(); a++) {
|
||||
if (CUtils::WildCmp(*a, sHostMask)) {
|
||||
if (CUtils::wildcmp(*a, sHostMask)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -131,7 +131,7 @@ void CUserSock::ReadLine(const string& sData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CUtils::WildCmp("DCC * (*)", sMsg.c_str())) {
|
||||
if (CUtils::wildcmp("DCC * (*)", sMsg.c_str())) {
|
||||
sMsg = "DCC " + CUtils::Token(sLine, 3) + " (" + ((m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP()) + ")";
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ void CUserSock::ReadLine(const string& sData) {
|
||||
}
|
||||
|
||||
#ifdef _MODULES
|
||||
if (CUtils::WildCmp("\001*\001", sMsg.c_str())) {
|
||||
if (CUtils::wildcmp("\001*\001", sMsg.c_str())) {
|
||||
string sCTCP = sMsg;
|
||||
CUtils::LeftChomp(sCTCP);
|
||||
CUtils::RightChomp(sCTCP);
|
||||
@@ -169,7 +169,7 @@ void CUserSock::ReadLine(const string& sData) {
|
||||
CUtils::LeftChomp(sMsg);
|
||||
}
|
||||
|
||||
if (CUtils::WildCmp("\001*\001", sMsg.c_str())) {
|
||||
if (CUtils::wildcmp("\001*\001", sMsg.c_str())) {
|
||||
string sCTCP = sMsg;
|
||||
CUtils::LeftChomp(sCTCP);
|
||||
CUtils::RightChomp(sCTCP);
|
||||
|
||||
@@ -212,51 +212,42 @@ string CUtils::Ellipsize(const string& s, unsigned int uLen) {
|
||||
return sRet;
|
||||
}
|
||||
|
||||
bool CUtils::WildCmp(const string& sWild, const string& sString) {
|
||||
char *wild = (char*) sWild.c_str();
|
||||
char *string = (char*) sString.c_str();
|
||||
bool CUtils::wildcmp(const string& sWild, const string& sString) {
|
||||
// Written by Jack Handy - jakkhandy@hotmail.com
|
||||
const char *wild = sWild.c_str(), *string = sString.c_str();
|
||||
const char *cp = NULL, *mp = NULL;
|
||||
|
||||
register int i, len;
|
||||
char *copy, *cp, *p, *lastmatch = string;
|
||||
|
||||
if ((p = strchr (wild, '*')) == NULL) {
|
||||
return (strcasecmp(wild, string) ? false : true);
|
||||
}
|
||||
|
||||
if (wild[0] != '*' && strncasecmp(string, wild, p-wild)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
len = strlen(wild) + 1;
|
||||
|
||||
if (wild[len -2] != '*') {
|
||||
p = strrchr(wild, '*') + 1;
|
||||
if (strcasecmp(string + strlen(string) - strlen(p), p) != 0) {
|
||||
while ((*string) && (*wild != '*')) {
|
||||
if ((*wild != *string) && (*wild != '?')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wild++;
|
||||
string++;
|
||||
}
|
||||
|
||||
cp = copy = (char*) malloc(len);
|
||||
memset((char*) copy, 0, len);
|
||||
|
||||
for (i=0; i<len; i++) {
|
||||
if (wild[i] == '*' || wild[i] == '\0') {
|
||||
if ((p = strcasestr(lastmatch, copy)) != NULL) {
|
||||
lastmatch = p + strlen(copy);
|
||||
memset((char*) copy, 0, len);
|
||||
cp = copy;
|
||||
continue;
|
||||
} else {
|
||||
free(copy);
|
||||
return false;
|
||||
while (*string) {
|
||||
if (*wild == '*') {
|
||||
if (!*++wild) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
*cp++ = wild[i];
|
||||
mp = wild;
|
||||
cp = string+1;
|
||||
} else if ((*wild == *string) || (*wild == '?')) {
|
||||
wild++;
|
||||
string++;
|
||||
} else {
|
||||
wild = mp;
|
||||
string = cp++;
|
||||
}
|
||||
}
|
||||
|
||||
free(copy);
|
||||
return true;
|
||||
while (*wild == '*') {
|
||||
wild++;
|
||||
}
|
||||
|
||||
return (*wild == 0);
|
||||
}
|
||||
|
||||
CTable::CTable() {}
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
static string& RightChomp(string& s, unsigned int uLen = 1);
|
||||
static string Token(const string& s, unsigned int uPos, bool bRest = false, char cSep = ' ');
|
||||
static string Ellipsize(const string& s, unsigned int uLen);
|
||||
static bool WildCmp(const string& sWild, const string& sString);
|
||||
static bool wildcmp(const string& sWild, const string& sString);
|
||||
private:
|
||||
protected:
|
||||
};
|
||||
|
||||
+2
-2
@@ -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 (CUtils::wildcmp(Lower(WatchSource.GetSource()), Lower(sSource))) {
|
||||
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 && CUtils::wildcmp(Lower(m_sHostMask), Lower(Nick.GetHostMask())) && CUtils::wildcmp(Lower(m_sPattern), Lower(sText)));
|
||||
}
|
||||
|
||||
bool operator ==(const CWatchEntry& WatchEntry) {
|
||||
|
||||
Reference in New Issue
Block a user