summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp4
-rw-r--r--src/connection.cpp4
-rw-r--r--src/dynamic.cpp2
-rw-r--r--src/inspircd.cpp226
-rw-r--r--src/modules.cpp66
-rw-r--r--src/modules/m_cloaking.cpp4
-rw-r--r--src/modules/m_foobar.cpp12
-rw-r--r--src/modules/m_randquote.cpp8
-rw-r--r--src/wildcard.cpp2
9 files changed, 163 insertions, 165 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 2a9a354a1..1d1b3edbe 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -14,11 +14,11 @@ chanrec::chanrec()
topiclock = noexternal = inviteonly = moderated = secret = c_private = false;
}
-chanrec::SetCustomMode(char mode,bool mode_on)
+void chanrec::SetCustomMode(char mode,bool mode_on)
{
}
-chanrec::SetCustomModeParam(char mode,char* parameter,bool mode_on)
+void chanrec::SetCustomModeParam(char mode,char* parameter,bool mode_on)
{
}
diff --git a/src/connection.cpp b/src/connection.cpp
index 6592cfd10..33eb405ad 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -7,8 +7,8 @@
#include "inspircd.h"
#include "modules.h"
-extern vector<Module*> modules;
-extern vector<ircd_module*> factory;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
extern int MODCOUNT;
diff --git a/src/dynamic.cpp b/src/dynamic.cpp
index e9cddcbbf..4c822e4ca 100644
--- a/src/dynamic.cpp
+++ b/src/dynamic.cpp
@@ -47,7 +47,7 @@ bool DLLManager::GetSymbol(
DLLFactoryBase::DLLFactoryBase(
const char *fname,
- const char *factory=0
+ const char *factory
) : DLLManager(fname)
{
// try get the factory function if there is no error yet
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 79e3c8b73..1f0a84c1c 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -28,8 +28,8 @@
#include <cstdio>
#include <time.h>
#include <string>
-#include <hash_map.h>
-#include <map.h>
+#include <hash_map>
+#include <map>
#include <sstream>
#include <vector>
#include <errno.h>
@@ -70,28 +70,30 @@ extern vector<ircd_module*> factory;
extern int MODCOUNT;
-template<> struct hash<in_addr>
+namespace __gnu_cxx
{
- size_t operator()(const struct in_addr &a) const
+ template<> struct __gnu_cxx::hash<in_addr>
{
- size_t q;
- memcpy(&q,&a,sizeof(size_t));
- return q;
- }
-};
+ size_t operator()(const struct in_addr &a) const
+ {
+ size_t q;
+ memcpy(&q,&a,sizeof(size_t));
+ return q;
+ }
+ };
-template<> struct hash<string>
-{
- size_t operator()(const string &s) const
+ template<> struct __gnu_cxx::hash<string>
{
- char a[MAXBUF];
- static struct hash<const char *> strhash;
- strcpy(a,s.c_str());
- strlower(a);
- return strhash(a);
- }
-};
-
+ size_t operator()(const string &s) const
+ {
+ char a[MAXBUF];
+ static struct hash<const char *> strhash;
+ strcpy(a,s.c_str());
+ strlower(a);
+ return strhash(a);
+ }
+ };
+}
struct StrHashComp
@@ -124,10 +126,10 @@ struct InAddr_HashComp
};
-typedef hash_map<string, userrec*, hash<string>, StrHashComp> user_hash;
-typedef hash_map<string, chanrec*, hash<string>, StrHashComp> chan_hash;
-typedef hash_map<in_addr,string*, hash<in_addr>, InAddr_HashComp> address_cache;
-typedef deque<command_t> command_table;
+typedef __gnu_cxx::hash_map<std::string, userrec*, __gnu_cxx::hash<string>, StrHashComp> user_hash;
+typedef __gnu_cxx::hash_map<std::string, chanrec*, __gnu_cxx::hash<string>, StrHashComp> chan_hash;
+typedef __gnu_cxx::hash_map<in_addr,string*, __gnu_cxx::hash<in_addr>, InAddr_HashComp> address_cache;
+typedef std::deque<command_t> command_table;
serverrec* me[32];
server_list* servers;
@@ -208,67 +210,66 @@ void chop(char* str)
}
-string getservername()
+std::string getservername()
{
return ServerName;
}
-string getserverdesc()
+std::string getserverdesc()
{
return ServerDesc;
}
-string getnetworkname()
+std::string getnetworkname()
{
return Network;
}
-string getadminname()
+std::string getadminname()
{
return AdminName;
}
-string getadminemail()
+std::string getadminemail()
{
return AdminEmail;
}
-string getadminnick()
+std::string getadminnick()
{
return AdminNick;
}
void log(int level,char *text, ...)
{
- char textbuffer[MAXBUF];
- va_list argsPtr;
- FILE *f;
- time_t rawtime;
- struct tm * timeinfo;
-
- if (level < LogLevel)
- return;
-
- time(&rawtime);
- timeinfo = localtime (&rawtime);
-
- f = fopen("ircd.log","a+");
- if (f)
- {
- char b[MAXBUF];
- va_start (argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
- strcpy(b,asctime(timeinfo));
- b[strlen(b)-1] = ':';
- fprintf(f,"%s %s\n",b,textbuffer);
- fclose(f);
- }
- else
- {
- printf("Can't write log file, bailing!!!");
- Exit(ERROR);
- }
+ char textbuffer[MAXBUF];
+ va_list argsPtr;
+ FILE *f;
+ time_t rawtime;
+ struct tm * timeinfo;
+ if (level < LogLevel)
+ return;
+
+ time(&rawtime);
+ timeinfo = localtime (&rawtime);
+
+ f = fopen("ircd.log","a+");
+ if (f)
+ {
+ char b[MAXBUF];
+ va_start (argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+ strcpy(b,asctime(timeinfo));
+ b[strlen(b)-1] = ':';
+ fprintf(f,"%s %s\n",b,textbuffer);
+ fclose(f);
+ }
+ else
+ {
+ printf("Can't write log file, bailing!!!");
+ Exit(ERROR);
+ }
}
void readfile(file_cache &F, const char* fname)
@@ -1648,6 +1649,7 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int
{
log(DEBUG,"process_modes: modechar: %c",modelist[ptr]);
+ char modechar = modelist[ptr];
switch (modelist[ptr])
{
case '-':
@@ -1906,18 +1908,18 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int
p.push_back(parameters[param]);
}
for (int i = 0; i <= MODCOUNT; i++)
- {
- if (modules[i]->OnExtendedMode(user,chan,modechar,MT_CHANNEL,mdir,p))
- {
- strcat(outlist,modelist[ptr]);
+ {
+ if (modules[i]->OnExtendedMode(user,chan,modechar,MT_CHANNEL,mdir,p))
+ {
+ char app[] = {modechar, 0};
+ strcat(outlist, app);
chan->SetCustomMode(modelist[ptr],mdir);
// include parameters in output if mode has them
- if ((ModeDefinedOn(modelist[ptr],MT_CHANNEL)>0) ||
- (ModeDefinedOff(modelist[ptr],MT_CHANNEL)>0))
- {
+ if ((ModeDefinedOn(modelist[ptr],MT_CHANNEL)>0) || (ModeDefinedOff(modelist[ptr],MT_CHANNEL)>0))
+ {
chan->SetCustomModeParam(modelist[ptr],parameters[param],mdir);
- strcpy(outpars[pc++],parameters[param++]);
- }
+ strcpy(outpars[pc++],parameters[param++]);
+ }
}
}
}
@@ -2365,11 +2367,11 @@ void handle_kick(char **parameters, int pcnt, userrec *user)
void handle_die(char **parameters, int pcnt, userrec *user)
{
- log(DEBUG,"die: %s",user->nick);
+ log(DEBUG,"die: %s",user->nick);
if (!strcmp(parameters[0],diepass))
{
WriteOpers("*** DIE command from %s!%s@%s, terminating...",user->nick,user->ident,user->host);
- sleep(DieDelay);
+ sleep(DieDelay);
Exit(ERROR);
}
else
@@ -2380,18 +2382,18 @@ void handle_die(char **parameters, int pcnt, userrec *user)
void handle_restart(char **parameters, int pcnt, userrec *user)
{
- log(DEBUG,"restart: %s",user->nick);
- if (!strcmp(parameters[0],restartpass))
+ log(DEBUG,"restart: %s",user->nick);
+ if (!strcmp(parameters[0],restartpass))
{
- WriteOpers("*** RESTART command from %s!%s@%s, Pretending to restart till this is finished :D",user->nick,user->ident,user->host);
- sleep(DieDelay);
- Exit(ERROR);
+ WriteOpers("*** RESTART command from %s!%s@%s, Pretending to restart till this is finished :D",user->nick,user->ident,user->host);
+ sleep(DieDelay);
+ Exit(ERROR);
/* Will finish this later when i can be arsed :) */
- }
- else
+ }
+ else
{
- WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
- }
+ WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
+ }
}
@@ -2468,14 +2470,14 @@ char* Passwd(userrec *user)
bool IsDenied(userrec *user)
{
- for (ClassVector::iterator i = Classes.begin(); i != Classes.end(); i++)
- {
- if (match(user->host,i->host) && (i->type == CC_DENY))
- {
- return true;
- }
- }
- return false;
+ for (ClassVector::iterator i = Classes.begin(); i != Classes.end(); i++)
+ {
+ if (match(user->host,i->host) && (i->type == CC_DENY))
+ {
+ return true;
+ }
+ }
+ return false;
}
@@ -2582,7 +2584,7 @@ void handle_topic(char **parameters, int pcnt, userrec *user)
void send_error(char *s)
{
- log(DEBUG,"send_error: %s",s);
+ log(DEBUG,"send_error: %s",s);
for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
{
WriteServ(i->second->fd,"NOTICE %s :%s",i->second->nick,s);
@@ -2591,31 +2593,31 @@ void send_error(char *s)
void Error(int status)
{
- signal (SIGALRM, SIG_IGN);
- signal (SIGPIPE, SIG_IGN);
- signal (SIGTERM, SIG_IGN);
- signal (SIGABRT, SIG_IGN);
- signal (SIGSEGV, SIG_IGN);
- signal (SIGURG, SIG_IGN);
- signal (SIGKILL, SIG_IGN);
- log(DEBUG,"*** fell down a pothole in the road to perfection ***");
- send_error("Error! Segmentation fault! save meeeeeeeeeeeeee *splat!*");
- exit(status);
+ signal (SIGALRM, SIG_IGN);
+ signal (SIGPIPE, SIG_IGN);
+ signal (SIGTERM, SIG_IGN);
+ signal (SIGABRT, SIG_IGN);
+ signal (SIGSEGV, SIG_IGN);
+ signal (SIGURG, SIG_IGN);
+ signal (SIGKILL, SIG_IGN);
+ log(DEBUG,"*** fell down a pothole in the road to perfection ***");
+ send_error("Error! Segmentation fault! save meeeeeeeeeeeeee *splat!*");
+ exit(status);
}
int main (int argc, char *argv[])
{
Start();
- log(DEBUG,"*** InspIRCd starting up!");
+ log(DEBUG,"*** InspIRCd starting up!");
if (!CheckConfig())
{
- log(DEBUG,"main: no config");
+ log(DEBUG,"main: no config");
printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n");
Exit(ERROR);
}
if (InspIRCd() == ERROR)
{
- log(DEBUG,"main: daemon function bailed");
+ log(DEBUG,"main: daemon function bailed");
printf("ERROR: could not initialise. Shutting down.\n");
Exit(ERROR);
}
@@ -2712,15 +2714,15 @@ void AddWhoWas(userrec* u)
/* add a client connection to the sockets list */
void AddClient(int socket, char* host, int port, bool iscached)
{
- int i;
- int blocking = 1;
- char resolved[MAXBUF];
- string tempnick;
- char tn2[MAXBUF];
- user_hash::iterator iter;
+ int i;
+ int blocking = 1;
+ char resolved[MAXBUF];
+ string tempnick;
+ char tn2[MAXBUF];
+ user_hash::iterator iter;
- tempnick = ConvToStr(socket) + "-unknown";
- sprintf(tn2,"%d-unknown",socket);
+ tempnick = ConvToStr(socket) + "-unknown";
+ sprintf(tn2,"%d-unknown",socket);
iter = clientlist.find(tempnick);
@@ -2736,7 +2738,7 @@ void AddClient(int socket, char* host, int port, bool iscached)
clientlist[tempnick] = new userrec();
NonBlocking(socket);
- log(DEBUG,"AddClient: %d %s %d",socket,host,port);
+ log(DEBUG,"AddClient: %d %s %d",socket,host,port);
clientlist[tempnick]->fd = socket;
@@ -3013,7 +3015,7 @@ void handle_quit(char **parameters, int pcnt, userrec *user)
void handle_who(char **parameters, int pcnt, userrec *user)
{
- chanrec* Ptr = null;
+ chanrec* Ptr = NULL;
/* theres more to do here, but for now just close the socket */
if (pcnt == 1)
@@ -4078,6 +4080,7 @@ int InspIRCd(void)
/* setup select call */
FD_ZERO(&selectFds);
log(DEBUG,"InspIRCd: startup: zero selects");
+ log(VERBOSE,"InspIRCd: startup: portCount = %d", portCount);
for (count = 0; count < portCount; count++)
{
@@ -4245,4 +4248,3 @@ int InspIRCd(void)
close (incomingSockfd);
}
-
diff --git a/src/modules.cpp b/src/modules.cpp
index 34c9bf125..75149aad0 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -6,7 +6,7 @@
#include <typeinfo>
-#include <iostream.h>
+#include <iostream>
#include "globals.h"
#include "modules.h"
#include "inspircd_io.h"
@@ -21,10 +21,10 @@ public:
bool default_on;
int params_when_on;
int params_when_off;
- void SetInfo(char mc, int ty, bool d_on, int p_on, int p_off) : modechar(mc), type(ty), default_on(d_on), params_when_on(p_on), params_when_off(p_off) { };
+ ExtMode(char mc, int ty, bool d_on, int p_on, int p_off) : modechar(mc), type(ty), default_on(d_on), params_when_on(p_on), params_when_off(p_off) { };
};
-typedef vector<ExtMode> ExtModeList;
+typedef std::vector<ExtMode> ExtModeList;
typedef ExtModeList::iterator ExtModeListIter;
ExtModeList EMode;
@@ -71,9 +71,7 @@ int ModeDefinedOff(char modechar, int type)
// returns true if an extended mode character is in use
bool AddExtendedMode(char modechar, int type, bool default_on, int params_on, int params_off)
{
- ExtMode Mode;
- Mode.SetInfo(modechar,type,default_on,params_on,params_off);
- EMode.push_back(Mode);
+ EMode.push_back( ExtMode (modechar,type,default_on,params_on,params_off));
return true;
}
@@ -84,7 +82,7 @@ Version::Version(int major, int minor, int revision, int build) : Major(major),
// admin is a simple class for holding a server's administrative info
-Admin::Admin(string name, string email, 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) { };
//
// Announce to the world that the Module base
@@ -100,7 +98,7 @@ void Module::OnUserPart(userrec* user, chanrec* channel) { }
void Module::OnPacketTransmit(char *p) { }
void Module::OnPacketReceive(char *p) { }
void Module::OnRehash() { }
-void Module::OnServerRaw(string &raw, bool inbound) { }
+void Module::OnServerRaw(std::string &raw, bool inbound) { }
bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params) { }
Version Module::GetVersion() { return Version(1,0,0,0); }
@@ -116,37 +114,37 @@ Server::~Server()
{
}
-void Server::SendOpers(string s)
+void Server::SendOpers(std::string s)
{
WriteOpers("%s",s.c_str());
}
-void Server::Log(int level, string s)
+void Server::Log(int level, std::string s)
{
log(level,"%s",s.c_str());
}
-void Server::Send(int Socket, string s)
+void Server::Send(int Socket, std::string s)
{
Write(Socket,"%s",s.c_str());
}
-void Server::SendServ(int Socket, string s)
+void Server::SendServ(int Socket, std::string s)
{
WriteServ(Socket,"%s",s.c_str());
}
-void Server::SendFrom(int Socket, userrec* User, string s)
+void Server::SendFrom(int Socket, userrec* User, std::string s)
{
WriteFrom(Socket,User,"%s",s.c_str());
}
-void Server::SendTo(userrec* Source, userrec* Dest, string s)
+void Server::SendTo(userrec* Source, userrec* Dest, std::string s)
{
WriteTo(Source,Dest,"%s",s.c_str());
}
-void Server::SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender)
+void Server::SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender)
{
if (IncludeSender)
{
@@ -163,7 +161,7 @@ bool Server::CommonChannels(userrec* u1, userrec* u2)
return (common_channels(u1,u2) != 0);
}
-void Server::SendCommon(userrec* User, string text,bool IncludeSender)
+void Server::SendCommon(userrec* User, std::string text,bool IncludeSender)
{
if (IncludeSender)
{
@@ -175,38 +173,37 @@ void Server::SendCommon(userrec* User, string text,bool IncludeSender)
}
}
-void Server::SendWallops(userrec* User, string text)
+void Server::SendWallops(userrec* User, std::string text)
{
WriteWallOps(User,"%s",text.c_str());
}
-bool Server::IsNick(string nick)
+bool Server::IsNick(std::string nick)
{
return (isnick(nick.c_str()) != 0);
}
-userrec* Server::FindNick(string nick)
+userrec* Server::FindNick(std::string nick)
{
return Find(nick);
}
-chanrec* Server::FindChannel(string channel)
+chanrec* Server::FindChannel(std::string channel)
{
return FindChan(channel.c_str());
}
-string Server::ChanMode(userrec* User, chanrec* Chan)
+std::string Server::ChanMode(userrec* User, chanrec* Chan)
{
- string mode = cmode(User,Chan);
- return mode;
+ return cmode(User,Chan);
}
-string Server::GetServerName()
+std::string Server::GetServerName()
{
return getservername();
}
-string Server::GetNetworkName()
+std::string Server::GetNetworkName()
{
return getnetworkname();
}
@@ -234,18 +231,17 @@ ConfigReader::~ConfigReader()
}
-ConfigReader::ConfigReader(string filename) : fname(filename) { };
+ConfigReader::ConfigReader(std::string filename) : fname(filename) { };
-string ConfigReader::ReadValue(string tag, string name, int index)
+std::string ConfigReader::ReadValue(std::string tag, std::string name, int index)
{
char val[MAXBUF];
ReadConf(fname.c_str(),tag.c_str(),name.c_str(),index,val);
- string s = val;
- return s;
+ return val;
}
-int ConfigReader::Enumerate(string tag)
+int ConfigReader::Enumerate(std::string tag)
{
return EnumConf(fname.c_str(),tag.c_str());
}
@@ -257,7 +253,7 @@ bool ConfigReader::Verify()
}
-FileReader::FileReader(string filename)
+FileReader::FileReader(std::string filename)
{
file_cache c;
readfile(c,filename.c_str());
@@ -268,7 +264,7 @@ FileReader::FileReader()
{
}
-void FileReader::LoadFile(string filename)
+void FileReader::LoadFile(std::string filename)
{
file_cache c;
readfile(c,filename.c_str());
@@ -279,7 +275,7 @@ FileReader::~FileReader()
{
}
-string FileReader::GetLine(int x)
+std::string FileReader::GetLine(int x)
{
if ((x<0) || (x>fc.size()))
return "";
@@ -292,8 +288,8 @@ int FileReader::FileSize()
}
-vector<Module*> modules(255);
-vector<ircd_module*> factory(255);
+std::vector<Module*> modules(255);
+std::vector<ircd_module*> factory(255);
int MODCOUNT = -1;
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index 46ed5cfec..d355ec657 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -32,13 +32,13 @@ class ModuleCloaking : public Module
{
if (strstr(user->dhost,"."))
{
- string a = strstr(user->dhost,".");
+ std::string a = strstr(user->dhost,".");
char ra[64];
long seed,s2;
memcpy(&seed,user->dhost,sizeof(long));
memcpy(&s2,a.c_str(),sizeof(long));
sprintf(ra,"%.8X",seed*s2*strlen(user->host));
- string b = Srv->GetNetworkName() + "-" + ra + a;
+ std::string b = Srv->GetNetworkName() + "-" + ra + a;
Srv->Log(DEBUG,"cloak: allocated "+b);
strcpy(user->dhost,b.c_str());
}
diff --git a/src/modules/m_foobar.cpp b/src/modules/m_foobar.cpp
index 0c8907bea..ab3fa759b 100644
--- a/src/modules/m_foobar.cpp
+++ b/src/modules/m_foobar.cpp
@@ -44,7 +44,7 @@ class ModuleFoobar : public Module
{
// method called when a user connects
- string b = user->nick;
+ std::string b = user->nick;
Srv->Log(DEBUG,"Foobar: User connecting: " + b);
}
@@ -52,7 +52,7 @@ class ModuleFoobar : public Module
{
// method called when a user disconnects
- string b = user->nick;
+ std::string b = user->nick;
Srv->Log(DEBUG,"Foobar: User quitting: " + b);
}
@@ -60,8 +60,8 @@ class ModuleFoobar : public Module
{
// method called when a user joins a channel
- string c = channel->name;
- string b = user->nick;
+ std::string c = channel->name;
+ std::string b = user->nick;
Srv->Log(DEBUG,"Foobar: User " + b + " joined " + c);
}
@@ -69,8 +69,8 @@ class ModuleFoobar : public Module
{
// method called when a user parts a channel
- string c = channel->name;
- string b = user->nick;
+ std::string c = channel->name;
+ std::string b = user->nick;
Srv->Log(DEBUG,"Foobar: User " + b + " parted " + c);
}
diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp
index aebf7c0ad..5be40bc6c 100644
--- a/src/modules/m_randquote.cpp
+++ b/src/modules/m_randquote.cpp
@@ -17,9 +17,9 @@ class ModuleRandQuote : public Module
ConfigReader *conf;
FileReader *quotes;
- string q_file;
- string prefix;
- string suffix;
+ std::string q_file;
+ std::string prefix;
+ std::string suffix;
public:
ModuleRandQuote()
@@ -48,7 +48,7 @@ class ModuleRandQuote : public Module
virtual void OnUserConnect(userrec* user)
{
- string str;
+ std::string str;
int fsize;
char buf[MAXBUF];
diff --git a/src/wildcard.cpp b/src/wildcard.cpp
index 900f314ea..41070d145 100644
--- a/src/wildcard.cpp
+++ b/src/wildcard.cpp
@@ -13,7 +13,7 @@ void Delete(char* str,int pos)
void Insert(char* substr,char* str,int pos)
{
- string a = str;
+ std::string a = str;
a.insert(pos,substr);
strcpy(str,a.c_str());
}