summaryrefslogtreecommitdiff
path: root/src/modules/m_nationalchars.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_nationalchars.cpp')
-rw-r--r--src/modules/m_nationalchars.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp
index b43b6e2b6..a668b7a2c 100644
--- a/src/modules/m_nationalchars.cpp
+++ b/src/modules/m_nationalchars.cpp
@@ -31,12 +31,12 @@
/* $ModDesc: Provides an ability to have non-RFC1459 nicks & support for national CASEMAPPING */
-class lwbNickHandler : public HandlerBase2<bool, const char*, size_t>
+class lwbNickHandler : public HandlerBase1<bool, const std::string&>
{
public:
lwbNickHandler() { }
- virtual ~lwbNickHandler() { }
- virtual bool Call(const char*, size_t);
+ ~lwbNickHandler() { }
+ bool Call(const std::string&);
};
/*,m_reverse_additionalUp[256];*/
@@ -71,11 +71,12 @@ char utf8size(unsigned char * mb)
/* Conditions added */
-bool lwbNickHandler::Call(const char* n, size_t max)
+bool lwbNickHandler::Call(const std::string& nick)
{
- if (!n || !*n)
+ if (nick.empty())
return false;
+ const char* n = nick.c_str();
unsigned int p = 0;
for (const char* i = n; *i; i++, p++)
{
@@ -215,17 +216,16 @@ bool lwbNickHandler::Call(const char* n, size_t max)
}
/* too long? or not -- pointer arithmetic rocks */
- return (p < max);
+ return (p < ServerInstance->Config->Limits.NickMax);
}
class ModuleNationalChars : public Module
{
- private:
lwbNickHandler myhandler;
std::string charset, casemapping;
unsigned char m_additional[256], m_additionalUp[256], m_lower[256], m_upper[256];
- caller2<bool, const char*, size_t> rememberer;
+ caller1<bool, const std::string&> rememberer;
bool forcequit;
const unsigned char * lowermap_rememberer;
@@ -235,7 +235,7 @@ class ModuleNationalChars : public Module
{
}
- void init()
+ void init() CXX11_OVERRIDE
{
memcpy(m_lower, rfc_case_insensitive_map, 256);
national_case_insensitive_map = m_lower;
@@ -247,14 +247,12 @@ class ModuleNationalChars : public Module
OnRehash(NULL);
}
- virtual void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
{
- std::string tmp(casemapping);
- tmp.insert(0, "CASEMAPPING=");
- SearchAndReplace(output, std::string("CASEMAPPING=rfc1459"), tmp);
+ tokens["CASEMAPPING"] = casemapping;
}
- virtual void OnRehash(User* user)
+ void OnRehash(User* user) CXX11_OVERRIDE
{
ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars");
charset = tag->getString("file");
@@ -276,19 +274,19 @@ class ModuleNationalChars : public Module
{
/* Fix by Brain: Dont quit UID users */
User* n = *iter;
- if (!isdigit(n->nick[0]) && !ServerInstance->IsNick(n->nick.c_str(), ServerInstance->Config->Limits.NickMax))
+ if (!isdigit(n->nick[0]) && !ServerInstance->IsNick(n->nick))
ServerInstance->Users->QuitUser(n, message);
}
}
- virtual ~ModuleNationalChars()
+ ~ModuleNationalChars()
{
ServerInstance->IsNick = rememberer;
national_case_insensitive_map = lowermap_rememberer;
CheckForceQuit("National characters module unloaded");
}
- virtual Version GetVersion()
+ Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides an ability to have non-RFC1459 nicks & support for national CASEMAPPING", VF_VENDOR | VF_COMMON, charset);
}
@@ -307,7 +305,7 @@ class ModuleNationalChars : public Module
std::ifstream ifs(filename.c_str());
if (ifs.fail())
{
- ServerInstance->Logs->Log("m_nationalchars",DEFAULT,"loadtables() called for missing file: %s", filename.c_str());
+ ServerInstance->Logs->Log("m_nationalchars", LOG_DEFAULT, "loadtables() called for missing file: %s", filename.c_str());
return;
}
@@ -322,7 +320,7 @@ class ModuleNationalChars : public Module
{
if (loadtable(ifs, tables[n], 255) && (n < faillimit))
{
- ServerInstance->Logs->Log("m_nationalchars",DEFAULT,"loadtables() called for illegal file: %s (line %d)", filename.c_str(), n+1);
+ ServerInstance->Logs->Log("m_nationalchars", LOG_DEFAULT, "loadtables() called for illegal file: %s (line %d)", filename.c_str(), n+1);
return;
}
}