X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules.cpp;h=bda6f765b232e2286f3df326391ac7c9453a108a;hb=25f6cb0fe66057f62c4c1d58beefe0595098897d;hp=334315d7202ba09aac99b3f0556daf64d3adfb19;hpb=de4a3f44b95620c1e220668517f5025039f07877;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules.cpp b/src/modules.cpp index 334315d72..bda6f765b 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -43,6 +43,7 @@ #include "typedefs.h" #include "modules.h" #include "command_parse.h" +#include "dns.h" extern ServerConfig *Config; extern InspIRCd* ServerInstance; @@ -63,17 +64,40 @@ featurelist Features; // version is a simple class for holding a modules version number -Version::Version(int major, int minor, int revision, int build, int flags) : Major(major), Minor(minor), Revision(revision), Build(build), Flags(flags) { }; +Version::Version(int major, int minor, int revision, int build, int flags) +: Major(major), Minor(minor), Revision(revision), Build(build), Flags(flags) +{ +} // admin is a simple class for holding a server's administrative info -Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { }; +Admin::Admin(std::string name, std::string email, std::string nick) +: Name(name), Email(email), Nick(nick) +{ +} -Request::Request(char* anydata, Module* src, Module* dst) : data(anydata), source(src), dest(dst) { }; +Request::Request(char* anydata, Module* src, Module* dst) +: data(anydata), source(src), dest(dst) +{ + /* Ensure that because this module doesnt support ID strings, it doesnt break modules that do + * by passing them uninitialized pointers (could happen) + */ + id = '\0'; +} + +Request::Request(Module* src, Module* dst, const char* idstr) +: id(idstr), source(src), dest(dst) +{ +}; char* Request::GetData() { - return (char*)this->data; + return this->data; +} + +const char* Request::GetId() +{ + return this->id; } Module* Request::GetSource() @@ -151,7 +175,7 @@ int Module::OnKill(userrec* source, userrec* dest, const std::string &reason) { void Module::OnLoadModule(Module* mod,const std::string &name) { }; void Module::OnUnloadModule(Module* mod,const std::string &name) { }; void Module::OnBackgroundTimer(time_t curtime) { }; -int Module::OnPreCommand(const std::string &command, char **parameters, int pcnt, userrec *user, bool validated) { return 0; }; +int Module::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) { return 0; }; bool Module::OnCheckReady(userrec* user) { return true; }; void Module::OnUserRegister(userrec* user) { }; int Module::OnUserPreKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { return 0; }; @@ -161,7 +185,7 @@ int Module::OnCheckInvite(userrec* user, chanrec* chan) { return 0; }; int Module::OnCheckKey(userrec* user, chanrec* chan, const std::string &keygiven) { return 0; }; int Module::OnCheckLimit(userrec* user, chanrec* chan) { return 0; }; int Module::OnCheckBan(userrec* user, chanrec* chan) { return 0; }; -int Module::OnStats(char symbol, userrec* user) { return 0; }; +int Module::OnStats(char symbol, userrec* user, string_list &results) { return 0; }; int Module::OnChangeLocalUserHost(userrec* user, const std::string &newhost) { return 0; }; int Module::OnChangeLocalUserGECOS(userrec* user, const std::string &newhost) { return 0; }; int Module::OnLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic) { return 0; }; @@ -294,6 +318,7 @@ Module* Server::FindFeature(const std::string &FeatureName) const std::string& Server::GetModuleName(Module* m) { + static std::string nothing = ""; /* Prevent compiler warning */ for (int i = 0; i <= MODCOUNT; i++) { if (modules[i] == m) @@ -301,7 +326,7 @@ const std::string& Server::GetModuleName(Module* m) return Config->module_names[i]; } } - return ""; + return nothing; /* As above */ } void Server::RehashServer() @@ -403,11 +428,11 @@ void Server::KickUser(userrec* source, userrec* target, chanrec* chan, const std { if (source) { - kick_channel(source,target,chan,(char*)reason.c_str()); + chan->KickUser(source, target, reason.c_str()); } else { - server_kick_channel(target,chan,(char*)reason.c_str(),true); + chan->ServerKickUser(target, reason.c_str(), true); } } @@ -421,7 +446,7 @@ bool Server::IsUlined(const std::string &server) return is_uline(server.c_str()); } -bool Server::CallCommandHandler(const std::string &commandname, char** parameters, int pcnt, userrec* user) +bool Server::CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user) { return ServerInstance->Parser->CallHandler(commandname,parameters,pcnt,user); } @@ -445,9 +470,9 @@ void Server::AddCommand(command_t *f) } } -void Server::SendMode(char **parameters, int pcnt, userrec *user) +void Server::SendMode(const char** parameters, int pcnt, userrec *user) { - //ServerInstance->ModeGrok->ServerMode(parameters,pcnt,user); + ServerInstance->ModeGrok->Process(parameters,pcnt,user,true); } void Server::Send(int Socket, const std::string &s) @@ -595,6 +620,21 @@ bool Server::AddMode(ModeHandler* mh, const unsigned char mode) return ServerInstance->ModeGrok->AddMode(mh,mode); } +bool Server::AddModeWatcher(ModeWatcher* mw) +{ + return ServerInstance->ModeGrok->AddModeWatcher(mw); +} + +bool Server::DelModeWatcher(ModeWatcher* mw) +{ + return ServerInstance->ModeGrok->DelModeWatcher(mw); +} + +bool Server::AddResolver(Resolver* r) +{ + return ServerInstance->Res->AddResolverClass(r); +} + int Server::CountUsers(chanrec* c) { return usercount(c); @@ -920,17 +960,43 @@ FileReader::FileReader(const std::string &filename) file_cache c; readfile(c,filename.c_str()); this->fc = c; + this->CalcSize(); } FileReader::FileReader() { } +std::string FileReader::Contents() +{ + std::string x = ""; + for (file_cache::iterator a = this->fc.begin(); a != this->fc.end(); a++) + { + x.append(*a); + x.append("\r\n"); + } + return x; +} + +unsigned long FileReader::ContentSize() +{ + return this->contentsize; +} + +void FileReader::CalcSize() +{ + unsigned long n = 0; + for (file_cache::iterator a = this->fc.begin(); a != this->fc.end(); a++) + n += (a->length() + 2); + this->contentsize = n; +} + void FileReader::LoadFile(const std::string &filename) { file_cache c; readfile(c,filename.c_str()); this->fc = c; + this->CalcSize(); }