* ---------------------------------------------------
*/
-#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)
{
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, const 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, const std::string &original_line) { return 0; };
+void Module::OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line) { };
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; };
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) { };
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)
{
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
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);
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)
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)
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));
}
- this->SE->DelFd(old_fd);
+ this->SE->DelFd(user);
shutdown(old_fd,2);
close(old_fd);
return true;
bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &message)
{
- 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
local_users.erase(find(local_users.begin(),local_users.end(),alive));
}
// 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++)
{
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;
}
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