]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Fix test client error cheecking on result types
[user/henk/code/inspircd.git] / src / modules.cpp
index 2c72943ec9cbf078b5798a07adc31ba928721873..ca533b5234080c60c1cd3351376e9cadb4d07829 100644 (file)
@@ -43,6 +43,7 @@
 #include "typedefs.h"
 #include "modules.h"
 #include "command_parse.h"
+#include "dns.h"
 
 extern ServerConfig *Config;
 extern InspIRCd* ServerInstance;
@@ -151,7 +152,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; };
@@ -292,6 +293,19 @@ Module* Server::FindFeature(const std::string &FeatureName)
        return iter->second;
 }
 
+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)
+               {
+                       return Config->module_names[i];
+               }
+       }
+       return nothing; /* As above */
+}
+
 void Server::RehashServer()
 {
        WriteOpers("*** Rehashing config file");
@@ -409,7 +423,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);
 }
@@ -433,7 +447,7 @@ 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);
 }
@@ -583,6 +597,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 dns_add_class(r);
+}
+
 int Server::CountUsers(chanrec* c)
 {
        return usercount(c);
@@ -908,17 +937,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();
 }