mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
STL namespace fixes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@176 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
e1cc6b33f4
commit
61b45c935d
@ -53,15 +53,15 @@ class InviteItem : public HostItem
|
||||
|
||||
/** Holds a complete ban list
|
||||
*/
|
||||
typedef vector<BanItem> BanList;
|
||||
typedef std::vector<BanItem> BanList;
|
||||
|
||||
/** Holds a complete exempt list
|
||||
*/
|
||||
typedef vector<ExemptItem> ExemptList;
|
||||
typedef std::vector<ExemptItem> ExemptList;
|
||||
|
||||
/** Holds a complete invite list
|
||||
*/
|
||||
typedef vector<InviteItem> InviteList;
|
||||
typedef std::vector<InviteItem> InviteList;
|
||||
|
||||
/** Holds all relevent information for a channel.
|
||||
* This class represents a channel, and contains its name, modes, time created, topic, topic set time,
|
||||
@ -135,11 +135,11 @@ class chanrec : public classbase
|
||||
|
||||
/** Sets or unsets a custom mode in the channels info
|
||||
*/
|
||||
SetCustomMode(char mode,bool mode_on);
|
||||
void SetCustomMode(char mode,bool mode_on);
|
||||
|
||||
/** Sets or unsets the parameterrs for a custom mode in a channels info
|
||||
*/
|
||||
SetCustomModeParam(char mode,char* parameter,bool mode_on);
|
||||
void SetCustomModeParam(char mode,char* parameter,bool mode_on);
|
||||
|
||||
/** Creates a channel record and initialises it with default values
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "inspircd_config.h"
|
||||
#include "base.h"
|
||||
#include <string>
|
||||
#include <map.h>
|
||||
#include <map>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <netdb.h>
|
||||
|
@ -10,13 +10,13 @@
|
||||
// include the common header files
|
||||
|
||||
#include <typeinfo>
|
||||
#include <iostream.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <deque>
|
||||
#include "users.h"
|
||||
#include "channels.h"
|
||||
|
||||
typedef deque<string> file_cache;
|
||||
typedef std::deque<std::string> file_cache;
|
||||
|
||||
void WriteOpers(char* text, ...);
|
||||
void log(int level, char *text, ...);
|
||||
@ -31,14 +31,15 @@ void WriteCommon(userrec *u, char* text, ...);
|
||||
void WriteCommonExcept(userrec *u, char* text, ...);
|
||||
void WriteWallOps(userrec *source, char* text, ...);
|
||||
int isnick(const char *n);
|
||||
userrec* Find(string nick);
|
||||
userrec* Find(std::string nick);
|
||||
chanrec* FindChan(const char* chan);
|
||||
char* cmode(userrec *user, chanrec *chan);
|
||||
string getservername();
|
||||
string getnetworkname();
|
||||
string getadminname();
|
||||
string getadminemail();
|
||||
string getadminnick();
|
||||
std::string getservername();
|
||||
std::string getnetworkname();
|
||||
std::string getadminname();
|
||||
std::string getadminemail();
|
||||
std::string getadminnick();
|
||||
void readfile(file_cache &F, const char* fname);
|
||||
int ModeDefiend(char c, int i);
|
||||
|
||||
#endif
|
||||
|
@ -46,7 +46,7 @@
|
||||
#define SPARSE 40
|
||||
#define NONE 50
|
||||
|
||||
typedef deque<string> file_cache;
|
||||
typedef std::deque<std::string> file_cache;
|
||||
|
||||
/* prototypes */
|
||||
int InspIRCd(void);
|
||||
@ -69,14 +69,16 @@ void WriteCommon(userrec *u, char* text, ...);
|
||||
void WriteCommonExcept(userrec *u, char* text, ...);
|
||||
void WriteWallOps(userrec *source, char* text, ...);
|
||||
int isnick(const char *n);
|
||||
userrec* Find(string nick);
|
||||
userrec* Find(std::string nick);
|
||||
chanrec* FindChan(const char* chan);
|
||||
char* cmode(userrec *user, chanrec *chan);
|
||||
string getservername();
|
||||
string getserverdesc();
|
||||
string getnetworkname();
|
||||
string getadminname();
|
||||
string getadminemail();
|
||||
string getadminnick();
|
||||
std::string getservername();
|
||||
std::string getserverdesc();
|
||||
std::string getnetworkname();
|
||||
std::string getadminname();
|
||||
std::string getadminemail();
|
||||
std::string getadminnick();
|
||||
void readfile(file_cache &F, const char* fname);
|
||||
|
||||
bool ModeDefined(char c, int i);
|
||||
bool ModeDefinedOn(char c, int i);
|
||||
bool ModeDefinedOff(char c, int i);
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
/** Low level definition of a FileReader classes file cache area
|
||||
*/
|
||||
typedef deque<string> file_cache;
|
||||
typedef std::deque<std::string> file_cache;
|
||||
typedef file_cache string_list;
|
||||
|
||||
// This #define allows us to call a method in all
|
||||
@ -56,8 +56,8 @@ class Version : public classbase
|
||||
class Admin : public classbase
|
||||
{
|
||||
public:
|
||||
const string Name, Email, Nick;
|
||||
Admin(string name,string email,string nick);
|
||||
const std::string Name, Email, Nick;
|
||||
Admin(std::string name, std::string email, std::string nick);
|
||||
};
|
||||
|
||||
/** Base class for all InspIRCd modules
|
||||
@ -137,7 +137,7 @@ class Module : public classbase
|
||||
* the string parameter "raw". If you do this, after your function exits it will immediately be
|
||||
* cut down to 510 characters plus a carriage return and linefeed.
|
||||
*/
|
||||
virtual void OnServerRaw(string &raw, bool inbound);
|
||||
virtual void OnServerRaw(std::string &raw, bool inbound);
|
||||
|
||||
/** Called whenever an extended mode is to be processed.
|
||||
* The type parameter is MT_SERVER, MT_CLIENT or MT_CHANNEL, dependent on where the mode is being
|
||||
@ -172,39 +172,39 @@ class Server : public classbase
|
||||
/** Sends text to all opers.
|
||||
* This method sends a server notice to all opers with the usermode +s.
|
||||
*/
|
||||
virtual void SendOpers(string s);
|
||||
virtual void SendOpers(std::string s);
|
||||
/** Writes a log string.
|
||||
* This method writes a line of text to the log. If the level given is lower than the
|
||||
* level given in the configuration, this command has no effect.
|
||||
*/
|
||||
virtual void Log(int level, string s);
|
||||
virtual void Log(int level, std::string s);
|
||||
/** Sends a line of text down a TCP/IP socket.
|
||||
* This method writes a line of text to an established socket, cutting it to 510 characters
|
||||
* plus a carriage return and linefeed if required.
|
||||
*/
|
||||
virtual void Send(int Socket, string s);
|
||||
virtual void Send(int Socket, std::string s);
|
||||
/** Sends text from the server to a socket.
|
||||
* This method writes a line of text to an established socket, with the servername prepended
|
||||
* as used by numerics (see RFC 1459)
|
||||
*/
|
||||
virtual void SendServ(int Socket, string s);
|
||||
virtual void SendServ(int Socket, std::string s);
|
||||
/** Sends text from a user to a socket.
|
||||
* This method writes a line of text to an established socket, with the given user's nick/ident
|
||||
* /host combination prepended, as used in PRIVSG etc commands (see RFC 1459)
|
||||
*/
|
||||
virtual void SendFrom(int Socket, userrec* User, string s);
|
||||
virtual void SendFrom(int Socket, userrec* User, std::string s);
|
||||
/** Sends text from a user to another user.
|
||||
* This method writes a line of text to a user, with a user's nick/ident
|
||||
* /host combination prepended, as used in PRIVMSG etc commands (see RFC 1459)
|
||||
*/
|
||||
virtual void SendTo(userrec* Source, userrec* Dest, string s);
|
||||
virtual void SendTo(userrec* Source, userrec* Dest, std::string s);
|
||||
/** Sends text from a user to a channel (mulicast).
|
||||
* This method writes a line of text to a channel, with the given user's nick/ident
|
||||
* /host combination prepended, as used in PRIVMSG etc commands (see RFC 1459). If the
|
||||
* IncludeSender flag is set, then the text is also sent back to the user from which
|
||||
* it originated, as seen in MODE (see RFC 1459).
|
||||
*/
|
||||
virtual void SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender);
|
||||
virtual void SendChannel(userrec* User, chanrec* Channel, std::string s,bool IncludeSender);
|
||||
/** Returns true if two users share a common channel.
|
||||
* This method is used internally by the NICK and QUIT commands, and the Server::SendCommon
|
||||
* method.
|
||||
@ -217,36 +217,36 @@ class Server : public classbase
|
||||
* back to the user from which it originated, as seen in NICK (see RFC 1459). Otherwise, it
|
||||
* is only sent to the other recipients, as seen in QUIT.
|
||||
*/
|
||||
virtual void SendCommon(userrec* User, string text,bool IncludeSender);
|
||||
virtual void SendCommon(userrec* User, std::string text,bool IncludeSender);
|
||||
/** Sends a WALLOPS message.
|
||||
* This method writes a WALLOPS message to all users with the +w flag, originating from the
|
||||
* specified user.
|
||||
*/
|
||||
virtual void SendWallops(userrec* User, string text);
|
||||
virtual void SendWallops(userrec* User, std::string text);
|
||||
|
||||
/** Returns true if a nick is valid.
|
||||
* Nicks for unregistered connections will return false.
|
||||
*/
|
||||
virtual bool IsNick(string nick);
|
||||
virtual bool IsNick(std::string nick);
|
||||
/** Attempts to look up a nick and return a pointer to it.
|
||||
* This function will return NULL if the nick does not exist.
|
||||
*/
|
||||
virtual userrec* FindNick(string nick);
|
||||
virtual userrec* FindNick(std::string nick);
|
||||
/** Attempts to look up a channel and return a pointer to it.
|
||||
* This function will return NULL if the channel does not exist.
|
||||
*/
|
||||
virtual chanrec* FindChannel(string channel);
|
||||
virtual chanrec* FindChannel(std::string channel);
|
||||
/** Attempts to look up a user's privilages on a channel.
|
||||
* This function will return a string containing either @, %, +, or an empty string,
|
||||
* representing the user's privilages upon the channel you specify.
|
||||
*/
|
||||
virtual string ChanMode(userrec* User, chanrec* Chan);
|
||||
virtual std::string ChanMode(userrec* User, chanrec* Chan);
|
||||
/** Returns the server name of the server where the module is loaded.
|
||||
*/
|
||||
virtual string GetServerName();
|
||||
virtual std::string GetServerName();
|
||||
/** Returns the network name, global to all linked servers.
|
||||
*/
|
||||
virtual string GetNetworkName();
|
||||
virtual std::string GetNetworkName();
|
||||
/** Returns the information of the server as returned by the /ADMIN command.
|
||||
* See the Admin class for further information of the return value. The members
|
||||
* Admin::Nick, Admin::Email and Admin::Name contain the information for the
|
||||
@ -285,7 +285,7 @@ class ConfigReader : public classbase
|
||||
protected:
|
||||
/** The filename of the configuration file, as set by the constructor.
|
||||
*/
|
||||
string fname;
|
||||
std::string fname;
|
||||
public:
|
||||
/** Default constructor.
|
||||
* This constructor initialises the ConfigReader class to read the inspircd.conf file
|
||||
@ -295,7 +295,7 @@ class ConfigReader : public classbase
|
||||
/** Overloaded constructor.
|
||||
* This constructor initialises the ConfigReader class to read a user-specified config file
|
||||
*/
|
||||
ConfigReader(string filename); // read a module-specific config
|
||||
ConfigReader(std::string filename); // read a module-specific config
|
||||
/** Default destructor.
|
||||
* This method destroys the ConfigReader class.
|
||||
*/
|
||||
@ -304,14 +304,14 @@ class ConfigReader : public classbase
|
||||
* This method retrieves a value from the config file. Where multiple copies of the tag
|
||||
* exist in the config file, index indicates which of the values to retrieve.
|
||||
*/
|
||||
string ReadValue(string tag, string name, int index);
|
||||
std::string ReadValue(std::string tag, std::string name, int index);
|
||||
/** Counts the number of times a given tag appears in the config file.
|
||||
* This method counts the number of times a tag appears in a config file, for use where
|
||||
* there are several tags of the same kind, e.g. with opers and connect types. It can be
|
||||
* used with the index value of ConfigReader::ReadValue to loop through all copies of a
|
||||
* multiple instance tag.
|
||||
*/
|
||||
int Enumerate(string tag);
|
||||
int Enumerate(std::string tag);
|
||||
/** Returns true if a config file is valid.
|
||||
* This method is unimplemented and will always return true.
|
||||
*/
|
||||
@ -339,7 +339,7 @@ class FileReader : public classbase
|
||||
* and other methods to be called. If the file could not be loaded, FileReader::FileSize
|
||||
* returns 0.
|
||||
*/
|
||||
FileReader(string filename);
|
||||
FileReader(std::string filename);
|
||||
/** Default destructor.
|
||||
* This deletes the memory allocated to the file.
|
||||
*/
|
||||
@ -349,12 +349,12 @@ class FileReader : public classbase
|
||||
* and other methods to be called. If the file could not be loaded, FileReader::FileSize
|
||||
* returns 0.
|
||||
*/
|
||||
void LoadFile(string filename);
|
||||
void LoadFile(std::string filename);
|
||||
/** Retrieve one line from the file.
|
||||
* This method retrieves one line from the text file. If an empty non-NULL string is returned,
|
||||
* the index was out of bounds, or the line had no data on it.
|
||||
*/
|
||||
string GetLine(int x);
|
||||
std::string GetLine(int x);
|
||||
/** Returns the size of the file in lines.
|
||||
* This method returns the number of lines in the read file. If it is 0, no lines have been
|
||||
* read into memory, either because the file is empty or it does not exist, or cannot be
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "inspircd_config.h"
|
||||
#include "connection.h"
|
||||
#include <string>
|
||||
#include <map.h>
|
||||
#include <map>
|
||||
|
||||
#ifndef __SERVERS_H__
|
||||
#define __SERVERS_H__
|
||||
@ -58,7 +58,7 @@ class serverrec : public connection
|
||||
|
||||
|
||||
|
||||
typedef map<string, serverrec*> server_list;
|
||||
typedef std::map<std::string, serverrec*> server_list;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -41,13 +41,13 @@ class ConnectClass : public classbase
|
||||
|
||||
/** Holds a complete list of all channels to which a user has been invited and has not yet joined.
|
||||
*/
|
||||
typedef vector<Invited> InvitedList;
|
||||
typedef std::vector<Invited> InvitedList;
|
||||
|
||||
|
||||
|
||||
/** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
|
||||
*/
|
||||
typedef vector<ConnectClass> ClassVector;
|
||||
typedef std::vector<ConnectClass> ClassVector;
|
||||
|
||||
/** Holds all information about a user
|
||||
* This class stores all information about a user connected to the irc server. Everything about a
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
222
src/inspircd.cpp
222
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;
|
||||
char textbuffer[MAXBUF];
|
||||
va_list argsPtr;
|
||||
FILE *f;
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
if (level < LogLevel)
|
||||
return;
|
||||
|
||||
if (level < LogLevel)
|
||||
return;
|
||||
time(&rawtime);
|
||||
timeinfo = localtime (&rawtime);
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 ¶ms) { }
|
||||
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;
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user