X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules.cpp;h=560fd6b2b0448e74db4fc133432c9f6d05526d06;hb=bb3aa2fb37071f48a5312df8688c0a6990644fbb;hp=ccd78a8f028c63d6790c04fa499a50c5d2ae9696;hpb=2c3745edb3013d4ffce393337566a8a58924740b;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules.cpp b/src/modules.cpp index ccd78a8f0..560fd6b2b 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -32,7 +32,7 @@ #include "dns.h" #include "exitcodes.h" -#ifndef WIN32 +#ifndef _WIN32 #include #endif @@ -95,7 +95,7 @@ void Module::OnUserPart(Membership*, std::string&, CUList&) { } void Module::OnPreRehash(User*, const std::string&) { } void Module::OnModuleRehash(User*, const std::string&) { } void Module::OnRehash(User*) { } -ModResult Module::OnUserPreJoin(User*, Channel*, const char*, std::string&, const std::string&) { return MOD_RES_PASSTHRU; } +ModResult Module::OnUserPreJoin(User*, Channel*, const std::string&, std::string&, const std::string&) { return MOD_RES_PASSTHRU; } void Module::OnMode(User*, void*, int, const std::vector&, const std::vector&) { } void Module::OnOper(User*, const std::string&) { } void Module::OnPostOper(User*, const std::string&, const std::string &) { } @@ -176,6 +176,7 @@ ModResult Module::OnNumeric(User*, unsigned int, const std::string&) { return MO void Module::OnHookIO(StreamSocket*, ListenSocket*) { } ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { return MOD_RES_PASSTHRU; } void Module::OnSendWhoLine(User*, const std::vector&, User*, std::string&) { } +void Module::OnSetUserIP(LocalUser*) { } ModuleManager::ModuleManager() : ModCount(0) { @@ -424,16 +425,6 @@ std::string& ModuleManager::LastError() return LastModuleError; } -CmdResult InspIRCd::CallCommandHandler(const std::string &commandname, const std::vector& parameters, User* user) -{ - return this->Parser->CallHandler(commandname, parameters, user); -} - -bool InspIRCd::IsValidModuleCommand(const std::string &commandname, int pcnt, User* user) -{ - return this->Parser->IsValidCommand(commandname, pcnt, user); -} - void ModuleManager::AddService(ServiceProvider& item) { switch (item.service) @@ -447,7 +438,8 @@ void ModuleManager::AddService(ServiceProvider& item) throw ModuleException("Mode "+std::string(item.name)+" already exists."); return; case SERVICE_METADATA: - ServerInstance->Extensions.Register(static_cast(&item)); + if (!ServerInstance->Extensions.Register(static_cast(&item))) + throw ModuleException("Extension " + std::string(item.name) + " already exists."); return; case SERVICE_DATA: case SERVICE_IOHOOK: @@ -557,7 +549,7 @@ dynamic_reference_base::operator bool() if (i != ServerInstance->Modules->DataProviders.end()) value = static_cast(i->second); } - return value; + return (value != NULL); } void InspIRCd::SendMode(const std::vector& parameters, User *user) @@ -604,93 +596,6 @@ const std::vector ModuleManager::GetAllModuleNames(int filter) return retval; } -ConfigReader::ConfigReader() -{ - this->error = 0; - ServerInstance->Logs->Log("MODULE", DEBUG, "ConfigReader is deprecated in 2.0; " - "use ServerInstance->Config->ConfValue(\"key\") or ->ConfTags(\"key\") instead"); -} - - -ConfigReader::~ConfigReader() -{ -} - -static ConfigTag* SlowGetTag(const std::string &tag, int index) -{ - ConfigTagList tags = ServerInstance->Config->ConfTags(tag); - while (tags.first != tags.second) - { - if (!index) - return tags.first->second; - tags.first++; - index--; - } - return NULL; -} - -std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds) -{ - std::string result = default_value; - if (!SlowGetTag(tag, index)->readString(name, result, allow_linefeeds)) - { - this->error = CONF_VALUE_NOT_FOUND; - } - return result; -} - -std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, int index, bool allow_linefeeds) -{ - return ReadValue(tag, name, "", index, allow_linefeeds); -} - -bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, const std::string &default_value, int index) -{ - bool def = (default_value == "yes"); - return SlowGetTag(tag, index)->getBool(name, def); -} - -bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int index) -{ - return ReadFlag(tag, name, "", index); -} - - -int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive) -{ - int v = atoi(default_value.c_str()); - int result = SlowGetTag(tag, index)->getInt(name, v); - - if ((need_positive) && (result < 0)) - { - this->error = CONF_INT_NEGATIVE; - return 0; - } - - return result; -} - -int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, int index, bool need_positive) -{ - return ReadInteger(tag, name, "", index, need_positive); -} - -long ConfigReader::GetError() -{ - long olderr = this->error; - this->error = 0; - return olderr; -} - -int ConfigReader::Enumerate(const std::string &tag) -{ - ServerInstance->Logs->Log("MODULE", DEBUG, "Module is using ConfigReader::Enumerate on %s; this is slow!", - tag.c_str()); - int i=0; - while (SlowGetTag(tag, i)) i++; - return i; -} - FileReader::FileReader(const std::string &filename) { LoadFile(filename);