summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-08-23 19:37:03 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-08-23 19:37:03 +0200
commitbcdc3b0bb0ba957a9e99cd6db7f1242a9e587400 (patch)
treefe0c0962384f5f8aa83658fd5897aa13e29ce22e
parent2df0de3c9212f7ea74fcb9a0ccf20990e47e9f2e (diff)
parent0aa6c4134011006e6166c72d9c3162b054c01bbe (diff)
Merge branch 'master+ircstring'
-rw-r--r--include/command_parse.h2
-rw-r--r--include/hashcomp.h160
-rw-r--r--include/stdalgo.h67
-rw-r--r--include/typedefs.h2
-rw-r--r--src/command_parse.cpp4
-rw-r--r--src/configreader.cpp4
-rw-r--r--src/hashcomp.cpp18
-rw-r--r--src/modules/m_banredirect.cpp5
-rw-r--r--src/modules/m_blockamsg.cpp8
-rw-r--r--src/modules/m_cban.cpp12
-rw-r--r--src/modules/m_censor.cpp4
-rw-r--r--src/modules/m_dccallow.cpp6
-rw-r--r--src/modules/m_filter.cpp12
-rw-r--r--src/modules/m_knock.cpp6
-rw-r--r--src/modules/m_services_account.cpp2
-rw-r--r--src/modules/m_silence.cpp8
-rw-r--r--src/modules/m_spanningtree/link.h2
-rw-r--r--src/modules/m_spanningtree/main.cpp6
-rw-r--r--src/modules/m_spanningtree/server.cpp3
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp2
-rw-r--r--src/modules/m_spanningtree/utils.cpp18
-rw-r--r--src/modules/m_timedbans.cpp19
-rw-r--r--src/xline.cpp4
23 files changed, 144 insertions, 230 deletions
diff --git a/include/command_parse.h b/include/command_parse.h
index 0f39d3586..c3d67af23 100644
--- a/include/command_parse.h
+++ b/include/command_parse.h
@@ -85,7 +85,7 @@ class CoreExport CommandParser
* With one list it is much simpler, and is used in NAMES, WHOIS, PRIVMSG etc.
*
* If there is only one list and there are duplicates in it, then the command handler is only called for
- * unique items. Entries are compared using "irc comparision" (see irc::string).
+ * unique items. Entries are compared using "irc comparison".
* If the usemax parameter is true (the default) the function only parses until it reaches
* ServerInstance->Config->MaxTargets number of targets, to stop abuse via spam.
*
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 87b2636fc..f3b1ba6e9 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -40,11 +40,9 @@
* treat [ identical to {, ] identical to }, and \
* as identical to |.
*
- * Our hashing functions are designed to accept
- * std::string and compare/hash them as type irc::string
- * by converting them internally. This makes them
- * backwards compatible with other code which is not
- * aware of irc::string.
+ * There are functors that accept std::string and
+ * compare/hash them as type irc::string by using
+ * mapping arrays internally.
*******************************************************/
/** Seperate from the other casemap tables so that code *can* still exclusively rely on RFC casemapping
@@ -70,43 +68,31 @@ CoreExport extern unsigned const char ascii_case_insensitive_map[256];
*/
CoreExport extern unsigned const char rfc_case_sensitive_map[256];
-template<typename T> const T& SearchAndReplace(T& text, const T& pattern, const T& replace)
-{
- T replacement;
- if ((!pattern.empty()) && (!text.empty()))
- {
- for (std::string::size_type n = 0; n != text.length(); ++n)
- {
- if (text.length() >= pattern.length() && text.substr(n, pattern.length()) == pattern)
- {
- // Found the pattern in the text, replace it, and advance
- replacement.append(replace);
- n = n + pattern.length() - 1;
- }
- else
- {
- replacement += text[n];
- }
- }
- }
- text = replacement;
- return text;
-}
-
/** The irc namespace contains a number of helper classes.
*/
namespace irc
{
+ /** Check if two IRC object (e.g. nick or channel) names are equal.
+ * This function uses national_case_insensitive_map to determine equality, which, by default does comparison
+ * according to RFC 1459, treating certain otherwise non-identical characters as identical.
+ * @param s1 First string to compare
+ * @param s2 Second string to compare
+ * @return True if the two names are equal, false otherwise
+ */
+ CoreExport bool equals(const std::string& s1, const std::string& s2);
/** This class returns true if two strings match.
* Case sensitivity is ignored, and the RFC 'character set'
* is adhered to
*/
- struct CoreExport StrHashComp
+ struct StrHashComp
{
/** The operator () does the actual comparison in hash_map
*/
- bool operator()(const std::string& s1, const std::string& s2) const;
+ bool operator()(const std::string& s1, const std::string& s2) const
+ {
+ return equals(s1, s2);
+ }
};
struct insensitive
@@ -170,14 +156,15 @@ namespace irc
/** Joins the contents of a vector to a string.
* @param sequence Zero or more items to join.
- * @separator The character to place between the items.
+ * @param separator The character to place between the items, defaults to ' ' (space).
+ * @return Joined string.
*/
std::string CoreExport stringjoiner(const std::vector<std::string>& sequence, char separator = ' ');
/** irc::sepstream allows for splitting token seperated lists.
* Each successive call to sepstream::GetToken() returns
* the next token, until none remain, at which point the method returns
- * an empty string.
+ * false.
*/
class CoreExport sepstream
{
@@ -265,12 +252,6 @@ namespace irc
*/
bool GetToken(std::string &token);
- /** Fetch the next token from the stream as an irc::string
- * @param token The next token available, or an empty string if none remain
- * @return True if tokens are left to be read, false if the last token was just retrieved.
- */
- bool GetToken(irc::string &token);
-
/** Fetch the next token from the stream as an integer
* @param token The next token available, or undefined if none remain
* @return True if tokens are left to be read, false if the last token was just retrieved.
@@ -337,107 +318,4 @@ namespace irc
*/
long GetToken();
};
-
- struct hash
- {
- /** Hash an irc::string using RFC1459 case sensitivity rules
- * @param s A string to hash
- * @return The hash value
- */
- size_t CoreExport operator()(const irc::string &s) const;
- };
-}
-
-/* Define operators for using >> and << with irc::string to an ostream on an istream. */
-/* This was endless fun. No. Really. */
-/* It was also the first core change Ommeh made, if anyone cares */
-
-/** Operator << for irc::string
- */
-inline std::ostream& operator<<(std::ostream &os, const irc::string &str) { return os << str.c_str(); }
-
-/** Operator >> for irc::string
- */
-inline std::istream& operator>>(std::istream &is, irc::string &str)
-{
- std::string tmp;
- is >> tmp;
- str = tmp.c_str();
- return is;
-}
-
-/* Define operators for + and == with irc::string to std::string for easy assignment
- * and comparison
- *
- * Operator +
- */
-inline std::string operator+ (std::string& leftval, irc::string& rightval)
-{
- return leftval + std::string(rightval.c_str());
-}
-
-/* Define operators for + and == with irc::string to std::string for easy assignment
- * and comparison
- *
- * Operator +
- */
-inline irc::string operator+ (irc::string& leftval, std::string& rightval)
-{
- return leftval + irc::string(rightval.c_str());
-}
-
-/* Define operators for + and == with irc::string to std::string for easy assignment
- * and comparison
- *
- * Operator ==
- */
-inline bool operator== (const std::string& leftval, const irc::string& rightval)
-{
- return (leftval.c_str() == rightval);
-}
-
-/* Define operators for + and == with irc::string to std::string for easy assignment
- * and comparison
- *
- * Operator ==
- */
-inline bool operator== (const irc::string& leftval, const std::string& rightval)
-{
- return (leftval == rightval.c_str());
-}
-
-/* Define operators != for irc::string to std::string for easy comparison
- */
-inline bool operator!= (const irc::string& leftval, const std::string& rightval)
-{
- return !(leftval == rightval.c_str());
-}
-
-/* Define operators != for std::string to irc::string for easy comparison
- */
-inline bool operator!= (const std::string& leftval, const irc::string& rightval)
-{
- return !(leftval.c_str() == rightval);
-}
-
-/** Assign an irc::string to a std::string.
- */
-inline std::string assign(const irc::string &other) { return other.c_str(); }
-
-/** Assign a std::string to an irc::string.
- */
-inline irc::string assign(const std::string &other) { return other.c_str(); }
-
-/** Trim the leading and trailing spaces from a std::string.
- */
-inline std::string& trim(std::string &str)
-{
- std::string::size_type start = str.find_first_not_of(" ");
- std::string::size_type end = str.find_last_not_of(" ");
- if (start == std::string::npos || end == std::string::npos)
- str = "";
- else
- str = str.substr(start, end-start+1);
-
- return str;
}
diff --git a/include/stdalgo.h b/include/stdalgo.h
index 3e00a4cdc..f4465963a 100644
--- a/include/stdalgo.h
+++ b/include/stdalgo.h
@@ -64,6 +64,73 @@ namespace stdalgo
}
}
+ namespace string
+ {
+ /** Get underlying C string of the string passed as parameter. Useful in template functions.
+ * @param str C string
+ * @return Same as input
+ */
+ inline const char* tocstr(const char* str)
+ {
+ return str;
+ }
+
+ /** Get underlying C string of the string passed as parameter. Useful in template functions.
+ * @param str std::string object
+ * @return str.c_str()
+ */
+ inline const char* tocstr(const std::string& str)
+ {
+ return str.c_str();
+ }
+
+ /** Check if two strings are equal case insensitively.
+ * @param str1 First string to compare.
+ * @param str2 Second string to compare.
+ * @return True if the strings are equal case-insensitively, false otherwise.
+ */
+ template <typename S1, typename S2>
+ inline bool equalsci(const S1& str1, const S2& str2)
+ {
+ return (!strcasecmp(tocstr(str1), tocstr(str2)));
+ }
+
+ /** Replace first occurrence of a substring ('target') in a string ('str') with another string ('replacement').
+ * @param str String to perform replacement in
+ * @param target String to replace
+ * @param replacement String to put in place of 'target'
+ * @return True if 'target' was replaced with 'replacement', false if it was not found in 'str'.
+ */
+ template<typename CharT, typename Traits, typename Alloc>
+ inline bool replace(std::basic_string<CharT, Traits, Alloc>& str, const std::basic_string<CharT, Traits, Alloc>& target, const std::basic_string<CharT, Traits, Alloc>& replacement)
+ {
+ const typename std::basic_string<CharT, Traits, Alloc>::size_type p = str.find(target);
+ if (p == std::basic_string<CharT, Traits, Alloc>::npos)
+ return false;
+ str.replace(p, target.size(), replacement);
+ return true;
+ }
+
+ /** Replace all occurrences of a string ('target') in a string ('str') with another string ('replacement').
+ * @param str String to perform replacement in
+ * @param target String to replace
+ * @param replacement String to put in place of 'target'
+ */
+ template<typename CharT, typename Traits, typename Alloc>
+ inline void replace_all(std::basic_string<CharT, Traits, Alloc>& str, const std::basic_string<CharT, Traits, Alloc>& target, const std::basic_string<CharT, Traits, Alloc>& replacement)
+ {
+ if (target.empty())
+ return;
+
+ typename std::basic_string<CharT, Traits, Alloc>::size_type p = 0;
+ while ((p = str.find(target, p)) != std::basic_string<CharT, Traits, Alloc>::npos)
+ {
+ str.replace(p, target.size(), replacement);
+ p += replacement.size();
+ }
+ }
+ }
+
/**
* Deleter that uses operator delete to delete the item
*/
diff --git a/include/typedefs.h b/include/typedefs.h
index 48842ccf0..879ef0627 100644
--- a/include/typedefs.h
+++ b/include/typedefs.h
@@ -99,7 +99,7 @@ typedef std::map<std::string, XLineFactory*> XLineFactMap;
/** A map of XLines indexed by string
*/
-typedef std::map<irc::string, XLine *> XLineLookup;
+typedef std::map<std::string, XLine*, irc::insensitive_swo> XLineLookup;
/** A map of XLineLookup maps indexed by string
*/
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 7e0c1c76d..f3511b05b 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -60,7 +60,7 @@ bool CommandParser::LoopCall(User* user, Command* handler, const std::vector<std
*
* Only check for duplicates if there is one list (allow them in JOIN).
*/
- insp::flat_set<irc::string> dupes;
+ insp::flat_set<std::string, irc::insensitive_swo> dupes;
bool check_dupes = (extra < 0);
/* Create two sepstreams, if we have only one list, then initialize the second sepstream with
@@ -80,7 +80,7 @@ bool CommandParser::LoopCall(User* user, Command* handler, const std::vector<std
*/
while (items1.GetToken(item) && (!usemax || max++ < ServerInstance->Config->MaxTargets))
{
- if ((!check_dupes) || (dupes.insert(item.c_str()).second))
+ if ((!check_dupes) || (dupes.insert(item).second))
{
std::vector<std::string> new_parameters(parameters);
new_parameters[splithere] = item;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 8a432e82f..0299b326a 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -433,11 +433,11 @@ void ServerConfig::Fill()
throw CoreException(Network + " is not a valid network name. A network name must not contain spaces.");
std::string defbind = options->getString("defaultbind");
- if (assign(defbind) == "ipv4")
+ if (stdalgo::string::equalsci(defbind, "ipv4"))
{
WildcardIPv6 = false;
}
- else if (assign(defbind) == "ipv6")
+ else if (stdalgo::string::equalsci(defbind, "ipv6"))
{
WildcardIPv6 = true;
}
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 35e5f3671..2c7dca5b1 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -151,15 +151,7 @@ unsigned const char rfc_case_sensitive_map[256] = {
250, 251, 252, 253, 254, 255, // 250-255
};
-size_t CoreExport irc::hash::operator()(const irc::string &s) const
-{
- size_t t = 0;
- for (irc::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */
- t = 5 * t + national_case_insensitive_map[(unsigned char)*x];
- return t;
-}
-
-bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) const
+bool irc::equals(const std::string& s1, const std::string& s2)
{
const unsigned char* n1 = (const unsigned char*)s1.c_str();
const unsigned char* n2 = (const unsigned char*)s2.c_str();
@@ -280,14 +272,6 @@ bool irc::tokenstream::GetToken(std::string &token)
return true;
}
-bool irc::tokenstream::GetToken(irc::string &token)
-{
- std::string stdstring;
- bool returnval = GetToken(stdstring);
- token = assign(stdstring);
- return returnval;
-}
-
bool irc::tokenstream::GetToken(int &token)
{
std::string tok;
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp
index c44a10f05..f98cbd420 100644
--- a/src/modules/m_banredirect.cpp
+++ b/src/modules/m_banredirect.cpp
@@ -166,7 +166,7 @@ class BanRedirect : public ModeWatcher
return false;
}
- if (assign(channel->name) == mask[CHAN])
+ if (irc::equals(channel->name, mask[CHAN]))
{
source->WriteNumeric(690, channel->name, "You cannot set a ban redirection to the channel the ban is on");
return false;
@@ -199,8 +199,7 @@ class BanRedirect : public ModeWatcher
for(BanRedirectList::iterator redir = redirects->begin(); redir != redirects->end(); redir++)
{
- /* Ugly as fuck */
- if((irc::string(redir->targetchan.c_str()) == irc::string(mask[CHAN].c_str())) && (irc::string(redir->banmask.c_str()) == irc::string(param.c_str())))
+ if ((irc::equals(redir->targetchan, mask[CHAN])) && (irc::equals(redir->banmask, param)))
{
redirects->erase(redir);
diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp
index 9614203c3..266497b90 100644
--- a/src/modules/m_blockamsg.cpp
+++ b/src/modules/m_blockamsg.cpp
@@ -37,11 +37,11 @@ class BlockedMessage
{
public:
std::string message;
- irc::string target;
+ std::string target;
time_t sent;
BlockedMessage(const std::string& msg, const std::string& tgt, time_t when)
- : message(msg), target(tgt.c_str()), sent(when)
+ : message(msg), target(tgt), sent(when)
{
}
};
@@ -116,7 +116,7 @@ class ModuleBlockAmsg : public Module
// OR
// The number of target channels is equal to the number of channels the sender is on..a little suspicious.
// Check it's more than 1 too, or else users on one channel would have fun.
- if ((m && (m->message == parameters[1]) && (m->target != parameters[0]) && (ForgetDelay != -1) && (m->sent >= ServerInstance->Time()-ForgetDelay)) || ((targets > 1) && (targets == user->chans.size())))
+ if ((m && (m->message == parameters[1]) && (!irc::equals(m->target, parameters[0])) && (ForgetDelay != -1) && (m->sent >= ServerInstance->Time()-ForgetDelay)) || ((targets > 1) && (targets == user->chans.size())))
{
// Block it...
if (action == IBLOCK_KILLOPERS || action == IBLOCK_NOTICEOPERS)
@@ -134,7 +134,7 @@ class ModuleBlockAmsg : public Module
{
// If there's already a BlockedMessage allocated, use it.
m->message = parameters[1];
- m->target = parameters[0].c_str();
+ m->target = parameters[0];
m->sent = ServerInstance->Time();
}
else
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 2a969bec7..42cff2850 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -28,15 +28,13 @@
class CBan : public XLine
{
private:
- std::string displaytext;
- irc::string matchtext;
+ std::string matchtext;
public:
CBan(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& ch)
: XLine(s_time, d, src, re, "CBAN")
+ , matchtext(ch)
{
- this->displaytext = ch;
- this->matchtext = ch.c_str();
}
// XXX I shouldn't have to define this
@@ -47,14 +45,12 @@ public:
bool Matches(const std::string &s)
{
- if (matchtext == s)
- return true;
- return false;
+ return irc::equals(matchtext, s);
}
const std::string& Displayable()
{
- return displaytext;
+ return matchtext;
}
};
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index c8b6b73a8..d2a60275a 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -79,11 +79,11 @@ class ModuleCensor : public Module
{
if (index->second.empty())
{
- user->WriteNumeric(ERR_WORDFILTERED, ((target_type == TYPE_CHANNEL) ? ((Channel*)dest)->name : ((User*)dest)->nick), index->first, "Your message contained a censored word, and was blocked");
+ user->WriteNumeric(ERR_WORDFILTERED, ((target_type == TYPE_CHANNEL) ? ((Channel*)dest)->name : ((User*)dest)->nick), index->first.c_str(), "Your message contained a censored word, and was blocked");
return MOD_RES_DENY;
}
- SearchAndReplace(text2, index->first, index->second);
+ stdalgo::string::replace_all(text2, index->first, index->second);
}
}
text = text2.c_str();
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index d8fbef69a..edf9d012f 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -328,12 +328,12 @@ class ModuleDCCAllow : public Module
if (s == std::string::npos)
return MOD_RES_PASSTHRU;
- irc::string type = assign(buf.substr(0, s));
+ const std::string type = buf.substr(0, s);
ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow");
bool blockchat = conftag->getBool("blockchat");
- if (type == "SEND")
+ if (stdalgo::string::equalsci(type, "SEND"))
{
size_t first;
@@ -386,7 +386,7 @@ class ModuleDCCAllow : public Module
u->WriteNotice("If you trust " + user->nick + " and were expecting this, you can type /DCCALLOW HELP for information on the DCCALLOW system.");
return MOD_RES_DENY;
}
- else if ((type == "CHAT") && (blockchat))
+ else if ((blockchat) && (stdalgo::string::equalsci(type, "CHAT")))
{
user->WriteNotice("The user " + u->nick + " is not accepting DCC CHAT requests from you.");
u->WriteNotice(user->nick + " (" + user->ident + "@" + user->dhost + ") attempted to initiate a DCC CHAT session, which was blocked.");
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index a3e30ecb4..bd19a60ba 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -632,17 +632,15 @@ std::pair<bool, std::string> ModuleFilter::AddFilter(const std::string &freeform
bool ModuleFilter::StringToFilterAction(const std::string& str, FilterAction& fa)
{
- irc::string s(str.c_str());
-
- if (s == "gline")
+ if (stdalgo::string::equalsci(str, "gline"))
fa = FA_GLINE;
- else if (s == "block")
+ else if (stdalgo::string::equalsci(str, "block"))
fa = FA_BLOCK;
- else if (s == "silent")
+ else if (stdalgo::string::equalsci(str, "silent"))
fa = FA_SILENT;
- else if (s == "kill")
+ else if (stdalgo::string::equalsci(str, "kill"))
fa = FA_KILL;
- else if (s == "none")
+ else if (stdalgo::string::equalsci(str, "none"))
fa = FA_NONE;
else
return false;
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index a6352749f..cf623c4ab 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -98,14 +98,12 @@ class ModuleKnock : public Module
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
std::string knocknotify = ServerInstance->Config->ConfValue("knock")->getString("notify");
- irc::string notify(knocknotify.c_str());
-
- if (notify == "numeric")
+ if (stdalgo::string::equalsci(knocknotify, "numeric"))
{
cmd.sendnotice = false;
cmd.sendnumeric = true;
}
- else if (notify == "both")
+ else if (stdalgo::string::equalsci(knocknotify, "both"))
{
cmd.sendnotice = true;
cmd.sendnumeric = true;
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 559f28ea8..e97e1b02f 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -181,7 +181,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE
{
/* On nickchange, if they have +r, remove it */
- if (user->IsModeSet(m5) && assign(user->nick) != oldnick)
+ if ((user->IsModeSet(m5)) && (ServerInstance->FindNickOnly(oldnick) != user))
m5.RemoveMode(user);
}
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 0ec40a92f..cb065d2fc 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -167,8 +167,8 @@ class CommandSilence : public Command
for (silencelist::iterator i = sl->begin(); i != sl->end(); i++)
{
// search through for the item
- irc::string listitem = i->first.c_str();
- if (listitem == mask && i->second == pattern)
+ const std::string& listitem = i->first;
+ if ((irc::equals(listitem, mask)) && (i->second == pattern))
{
sl->erase(i);
user->WriteNumeric(950, user->nick, InspIRCd::Format("Removed %s %s from silence list", mask.c_str(), decomppattern.c_str()));
@@ -200,8 +200,8 @@ class CommandSilence : public Command
std::string decomppattern = DecompPattern(pattern);
for (silencelist::iterator n = sl->begin(); n != sl->end(); n++)
{
- irc::string listitem = n->first.c_str();
- if (listitem == mask && n->second == pattern)
+ const std::string& listitem = n->first;
+ if ((irc::equals(listitem, mask)) && (n->second == pattern))
{
user->WriteNumeric(952, user->nick, InspIRCd::Format("%s %s is already on your silence list", mask.c_str(), decomppattern.c_str()));
return CMD_FAILURE;
diff --git a/src/modules/m_spanningtree/link.h b/src/modules/m_spanningtree/link.h
index 21213fb3e..632982623 100644
--- a/src/modules/m_spanningtree/link.h
+++ b/src/modules/m_spanningtree/link.h
@@ -24,7 +24,7 @@ class Link : public refcountbase
{
public:
reference<ConfigTag> tag;
- irc::string Name;
+ std::string Name;
std::string IPAddr;
int Port;
std::string SendPass;
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 81543b0da..f26b3c828 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -194,7 +194,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
{
bool ipvalid = true;
- if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name), rfc_case_insensitive_map))
+ if (InspIRCd::Match(ServerInstance->Config->ServerName, x->Name, ascii_case_insensitive_map))
{
ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself.");
return;
@@ -318,9 +318,9 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para
for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++)
{
Link* x = *i;
- if (InspIRCd::Match(x->Name.c_str(),parameters[0], rfc_case_insensitive_map))
+ if (InspIRCd::Match(x->Name, parameters[0], ascii_case_insensitive_map))
{
- if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name), rfc_case_insensitive_map))
+ if (InspIRCd::Match(ServerInstance->Config->ServerName, x->Name, ascii_case_insensitive_map))
{
user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Server \002%s\002 is ME, not connecting.", x->Name.c_str()));
return MOD_RES_DENY;
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 3000dd391..50f63e117 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -98,7 +98,6 @@ Link* TreeSocket::AuthRemote(const parameterlist& params)
return NULL;
}
- irc::string servername = params[0].c_str();
const std::string& sname = params[0];
const std::string& password = params[1];
const std::string& sid = params[3];
@@ -115,7 +114,7 @@ Link* TreeSocket::AuthRemote(const parameterlist& params)
for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++)
{
Link* x = *i;
- if (x->Name != servername && x->Name != "*") // open link allowance
+ if ((!stdalgo::string::equalsci(x->Name, sname)) && (x->Name != "*")) // open link allowance
continue;
if (!ComparePass(*x, password))
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index e1642a086..a96c4a90c 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -37,7 +37,7 @@
* and only do minor initialization tasks ourselves.
*/
TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr)
- : linkID(assign(link->Name)), LinkState(CONNECTING), MyRoot(NULL), proto_version(0)
+ : linkID(link->Name), LinkState(CONNECTING), MyRoot(NULL), proto_version(0)
, burstsent(false), age(ServerInstance->Time())
{
capab = new CapabData;
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 6de47de94..c1c32e80a 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -267,31 +267,31 @@ void SpanningTreeUtilities::ReadConfiguration()
throw ModuleException("Invalid configuration, found a link tag without a name!" + (!L->IPAddr.empty() ? " IP address: "+L->IPAddr : ""));
if (L->Name.find('.') == std::string::npos)
- throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it must contain at least one '.' character");
+ throw ModuleException("The link name '"+L->Name+"' is invalid as it must contain at least one '.' character");
if (L->Name.length() > ServerInstance->Config->Limits.MaxHost)
- throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it is longer than " + ConvToStr(ServerInstance->Config->Limits.MaxHost) + " characters");
+ throw ModuleException("The link name '"+L->Name+"' is invalid as it is longer than " + ConvToStr(ServerInstance->Config->Limits.MaxHost) + " characters");
if (L->RecvPass.empty())
- throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', recvpass not defined");
+ throw ModuleException("Invalid configuration for server '"+L->Name+"', recvpass not defined");
if (L->SendPass.empty())
- throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', sendpass not defined");
+ throw ModuleException("Invalid configuration for server '"+L->Name+"', sendpass not defined");
if ((L->SendPass.find(' ') != std::string::npos) || (L->RecvPass.find(' ') != std::string::npos))
- throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that contains a space character which is invalid");
+ throw ModuleException("Link block '" + L->Name + "' has a password set that contains a space character which is invalid");
if ((L->SendPass[0] == ':') || (L->RecvPass[0] == ':'))
- throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that begins with a colon (:) which is invalid");
+ throw ModuleException("Link block '" + L->Name + "' has a password set that begins with a colon (:) which is invalid");
if (L->IPAddr.empty())
{
L->IPAddr = "*";
- ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + assign(L->Name) + "' has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want.");
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + L->Name + "' has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want.");
}
if (!L->Port)
- ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + assign(L->Name) + "' has no port defined, you will not be able to /connect it.");
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + L->Name + "' has no port defined, you will not be able to /connect it.");
L->Fingerprint.erase(std::remove(L->Fingerprint.begin(), L->Fingerprint.end(), ':'), L->Fingerprint.end());
LinkBlocks.push_back(L);
@@ -331,7 +331,7 @@ Link* SpanningTreeUtilities::FindLink(const std::string& name)
for (std::vector<reference<Link> >::iterator i = LinkBlocks.begin(); i != LinkBlocks.end(); ++i)
{
Link* x = *i;
- if (InspIRCd::Match(x->Name.c_str(), name.c_str(), rfc_case_insensitive_map))
+ if (InspIRCd::Match(x->Name, name, ascii_case_insensitive_map))
{
return x;
}
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index 8a627b9a6..874e6440f 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -28,7 +28,6 @@
class TimedBan
{
public:
- std::string channel;
std::string mask;
time_t expire;
Channel* chan;
@@ -83,7 +82,6 @@ class CommandTban : public Command
}
TimedBan T;
- std::string channelname = parameters[0];
unsigned long duration = InspIRCd::Duration(parameters[1]);
unsigned long expire = duration + ServerInstance->Time();
if (duration < 1)
@@ -114,7 +112,6 @@ class CommandTban : public Command
}
CUList tmp;
- T.channel = channelname;
T.mask = mask;
T.expire = expire + (IS_REMOTE(user) ? 5 : 0);
T.chan = channel;
@@ -147,13 +144,13 @@ class BanWatcher : public ModeWatcher
if (adding)
return;
- irc::string listitem = banmask.c_str();
- irc::string thischan = chan->name.c_str();
for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end(); ++i)
{
- irc::string target = i->mask.c_str();
- irc::string tchan = i->channel.c_str();
- if ((listitem == target) && (tchan == thischan))
+ if (i->chan != chan)
+ continue;
+
+ const std::string& target = i->mask;
+ if (irc::equals(banmask, target))
{
TimedBanList.erase(i);
break;
@@ -206,13 +203,11 @@ class ModuleTimedBans : public Module
for (timedbans::iterator i = expired.begin(); i != expired.end(); i++)
{
- std::string chan = i->channel;
std::string mask = i->mask;
- Channel* cr = ServerInstance->FindChan(chan);
- if (cr)
+ Channel* cr = i->chan;
{
CUList empty;
- std::string expiry = "*** Timed ban on " + chan + " expired.";
+ std::string expiry = "*** Timed ban on " + cr->name + " expired.";
cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str());
ServerInstance->PI->SendChannelNotice(cr, '@', expiry);
diff --git a/src/xline.cpp b/src/xline.cpp
index 30a1d7c9c..b116d2e1f 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -259,7 +259,7 @@ bool XLineManager::AddLine(XLine* line, User* user)
ContainerIter x = lookup_lines.find(line->type);
if (x != lookup_lines.end())
{
- LookupIter i = x->second.find(line->Displayable().c_str());
+ LookupIter i = x->second.find(line->Displayable());
if (i != x->second.end())
{
// XLine propagation bug was here, if the line to be added already exists and
@@ -281,7 +281,7 @@ bool XLineManager::AddLine(XLine* line, User* user)
if (xlf->AutoApplyToUserList(line))
pending_lines.push_back(line);
- lookup_lines[line->type][line->Displayable().c_str()] = line;
+ lookup_lines[line->type][line->Displayable()] = line;
line->OnAdd();
FOREACH_MOD(OnAddLine, (user, line));