]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Fix for parameters which contain a colon (which is not the first char in the string)
[user/henk/code/inspircd.git] / src / modules.cpp
index ed2d5a2fde0ff2d0c8136c158b2164c52dac2cef..d3db06d4593a66238b594b55da6a50d488f0a357 100644 (file)
  * ---------------------------------------------------
  */
 
-#include "inspircd_config.h"
-//#include "inspircd.h"
 #include "configreader.h"
-#include <unistd.h>
-#include <sys/errno.h>
-#include <time.h>
-#include <string>
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
 #include "users.h"
-#include "ctables.h"
-#include "globals.h"
 #include "modules.h"
-#include "dynamic.h"
 #include "wildcard.h"
 #include "mode.h"
 #include "xline.h"
-#include "commands.h"
-#include "inspstring.h"
-#include "helperfuncs.h"
-#include "hashcomp.h"
 #include "socket.h"
 #include "socketengine.h"
-#include "typedefs.h"
-#include "modules.h"
 #include "command_parse.h"
 #include "dns.h"
 #include "inspircd.h"
 
 // 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)
 {
@@ -169,7 +149,7 @@ void                Module::OnEvent(Event* event) { return; };
 char*          Module::OnRequest(Request* request) { return NULL; };
 int            Module::OnOperCompare(const std::string &password, const std::string &input) { return 0; };
 void           Module::OnGlobalOper(userrec* user) { };
-void           Module::OnGlobalConnect(userrec* user) { };
+void           Module::OnPostConnect(userrec* user) { };
 int            Module::OnAddBan(userrec* source, chanrec* channel,const std::string &banmask) { return 0; };
 int            Module::OnDelBan(userrec* source, chanrec* channel,const std::string &banmask) { return 0; };
 void           Module::OnRawSocketAccept(int fd, const std::string &ip, int localport) { };
@@ -209,25 +189,8 @@ void               Module::OnChannelDelete(chanrec* chan) { };
 Priority       Module::Prioritize() { return PRIORITY_DONTCARE; }
 void           Module::OnSetAway(userrec* user) { };
 void           Module::OnCancelAway(userrec* user) { };
+int            Module::OnUserList(userrec* user, chanrec* Ptr) { return 0; };
 
-/* server is a wrapper class that provides methods to all of the C-style
- * exports in the core
- */
-
-void InspIRCd::AddSocket(InspSocket* sock)
-{
-       this->module_sockets.push_back(sock);
-}
-
-void InspIRCd::RemoveSocket(InspSocket* sock)
-{
-       for (std::vector<InspSocket*>::iterator a = this->module_sockets.begin(); a < this->module_sockets.end(); a++)
-       {
-               InspSocket* s = (InspSocket*)*a;
-               if (s == sock)
-                       s->MarkAsClosed();
-       }
-}
 
 long InspIRCd::PriorityAfter(const std::string &modulename)
 {
@@ -303,18 +266,6 @@ void InspIRCd::RehashServer()
        this->Config->Read(false,NULL);
 }
 
-void InspIRCd::DelSocket(InspSocket* sock)
-{
-       for (std::vector<InspSocket*>::iterator a = this->module_sockets.begin(); a < this->module_sockets.end(); a++)
-       {
-               if (*a == sock)
-               {
-                       this->module_sockets.erase(a);
-                       return;
-               }
-       }
-}
-
 /* This is ugly, yes, but hash_map's arent designed to be
  * addressed in this manner, and this is a bit of a kludge.
  * Luckily its a specialist function and rarely used by
@@ -338,11 +289,6 @@ bool InspIRCd::MatchText(const std::string &sliteral, const std::string &spatter
        return match(sliteral.c_str(),spattern.c_str());
 }
 
-bool InspIRCd::IsUlined(const std::string &server)
-{
-       return is_uline(server.c_str());
-}
-
 bool InspIRCd::CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user)
 {
        return this->Parser->CallHandler(commandname,parameters,pcnt,user);
@@ -364,7 +310,7 @@ void InspIRCd::AddCommand(command_t *f)
 
 void InspIRCd::SendMode(const char** parameters, int pcnt, userrec *user)
 {
-       this->ModeGrok->Process(parameters,pcnt,user,true);
+       this->Modes->Process(parameters,pcnt,user,true);
 }
 
 void InspIRCd::DumpText(userrec* User, const std::string &LinePrefix, stringstream &TextStream)
@@ -385,22 +331,22 @@ void InspIRCd::DumpText(userrec* User, const std::string &LinePrefix, stringstre
 
 userrec* InspIRCd::FindDescriptor(int socket)
 {
-       return ((socket < MAX_DESCRIPTORS && socket > -1) ? this->fd_ref_table[socket] : NULL);
+       return reinterpret_cast<userrec*>(this->SE->GetRef(socket));
 }
 
 bool InspIRCd::AddMode(ModeHandler* mh, const unsigned char mode)
 {
-       return this->ModeGrok->AddMode(mh,mode);
+       return this->Modes->AddMode(mh,mode);
 }
 
 bool InspIRCd::AddModeWatcher(ModeWatcher* mw)
 {
-       return this->ModeGrok->AddModeWatcher(mw);
+       return this->Modes->AddModeWatcher(mw);
 }
 
 bool InspIRCd::DelModeWatcher(ModeWatcher* mw)
 {
-       return this->ModeGrok->DelModeWatcher(mw);
+       return this->Modes->DelModeWatcher(mw);
 }
 
 bool InspIRCd::AddResolver(Resolver* r)
@@ -410,19 +356,18 @@ bool InspIRCd::AddResolver(Resolver* r)
 
 bool InspIRCd::UserToPseudo(userrec* user, const std::string &message)
 {
-       unsigned int old_fd = user->fd;
+       unsigned int old_fd = user->GetFd();
        user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,message.c_str());
        user->FlushWriteBuf();
        user->ClearBuffer();
-       user->fd = FD_MAGIC_NUMBER;
+       user->SetFd(FD_MAGIC_NUMBER);
 
        if (find(local_users.begin(),local_users.end(),user) != local_users.end())
        {
                local_users.erase(find(local_users.begin(),local_users.end(),user));
-               log(DEBUG,"Delete local user");
        }
 
-       this->SE->DelFd(old_fd);
+       this->SE->DelFd(user);
        shutdown(old_fd,2);
        close(old_fd);
        return true;
@@ -430,10 +375,9 @@ bool InspIRCd::UserToPseudo(userrec* user, const std::string &message)
 
 bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &message)
 {
-       log(DEBUG,"PseudoToUser");
-       zombie->fd = alive->fd;
+       zombie->SetFd(alive->GetFd());
        FOREACH_MOD_I(this,I_OnUserQuit,OnUserQuit(alive,message));
-       alive->fd = FD_MAGIC_NUMBER;
+       alive->SetFd(FD_MAGIC_NUMBER);
        alive->FlushWriteBuf();
        alive->ClearBuffer();
        // save these for later
@@ -444,10 +388,8 @@ bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &
        if (find(local_users.begin(),local_users.end(),alive) != local_users.end())
        {
                local_users.erase(find(local_users.begin(),local_users.end(),alive));
-               log(DEBUG,"Delete local user");
        }
        // Fix by brain - cant write the user until their fd table entry is updated
-       this->fd_ref_table[zombie->fd] = zombie;
        zombie->Write(":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick);
        for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
        {
@@ -464,9 +406,8 @@ bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &
                                zombie->WriteServ("366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
                }
        }
-       if ((find(local_users.begin(),local_users.end(),zombie) == local_users.end()) && (zombie->fd != FD_MAGIC_NUMBER))
+       if ((find(local_users.begin(),local_users.end(),zombie) == local_users.end()) && (zombie->GetFd() != FD_MAGIC_NUMBER))
                local_users.push_back(zombie);
-
        return true;
 }
 
@@ -524,11 +465,6 @@ bool InspIRCd::DelELine(const std::string &hostmask)
        return XLines->del_eline(hostmask.c_str());
 }
 
-long InspIRCd::CalcDuration(const std::string &delta)
-{
-       return duration(delta.c_str());
-}
-
 /*
  * XXX why on *earth* is this in modules.cpp...? I think
  * perhaps we need a server.cpp for InspIRCd:: stuff where possible. -- w00t