The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

inspircd.h File Reference

#include <ctime>
#include <cstdarg>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdio>
#include <time.h>
#include <string>
#include <sstream>
#include <list>
#include "inspircd_config.h"
#include "users.h"
#include "channels.h"
#include "socket.h"
#include "mode.h"
#include "socketengine.h"
#include "command_parse.h"
#include "snomasks.h"
#include "cull_list.h"
#include <limits.h>

Include dependency graph for inspircd.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  serverstats
 This class contains various STATS counters It is used by the InspIRCd class, which internally has an instance of it. More...
class  FileLogger
 This class implements a nonblocking log-writer. More...
class  InspIRCd
 The main class of the irc server. More...

Defines

#define _FILE_OFFSET_BITS   64
#define DllExport
#define CoreExport
#define printf_c   printf
#define PATH_MAX   4096
#define ERROR   -1
 Returned by some functions to indicate failure.
#define ETIREDHAMSTERS   EAGAIN
 Support for librodent - see http://www.chatspike.net/index.php?z=64.
#define IS_SINGLE(x, y)   ( (*x == y) && (*(x+1) == 0) )
 This define is used in place of strcmp when we want to check if a char* string contains only one letter.

Typedefs

typedef std::vector< std::pair<
std::string, std::string > > 
FailedPortList
 A list of failed port bindings, used for informational purposes on startup.
typedef std::map< irc::string,
unsigned int > 
clonemap
 A list of ip addresses cross referenced against clone counts.

Enumerations

enum  DebugLevel {
  DEBUG = 10, VERBOSE = 20, DEFAULT = 30, SPARSE = 40,
  NONE = 50
}
 Debug levels for use with InspIRCd::Log(). More...

Functions

template<typename T>
void DELETE (T *x)
 Delete a pointer, and NULL its value.
template<typename T>
std::string ConvNumeric (const T &in)
 Template function to convert any input type to std::string.
std::string ConvToStr (const int in)
 Template function to convert any input type to std::string.
std::string ConvToStr (const long in)
 Template function to convert any input type to std::string.
std::string ConvToStr (const unsigned long in)
 Template function to convert any input type to std::string.
std::string ConvToStr (const char *in)
 Template function to convert any input type to std::string.
std::string ConvToStr (const bool in)
 Template function to convert any input type to std::string.
std::string ConvToStr (char in)
 Template function to convert any input type to std::string.
template<class T>
std::string ConvToStr (const T &in)
 Template function to convert any input type to std::string.
template<typename T>
long ConvToInt (const T &in)
 Template function to convert any input type to any other type (usually an integer or numeric type).
template<typename T, typename V, typename R>
char * itoa (const T &in, V *res, R base)
 Template function to convert integer to char, storing result in *res and also returning the pointer to res.


Define Documentation

#define _FILE_OFFSET_BITS   64
 

Definition at line 17 of file inspircd.h.

#define CoreExport
 

Definition at line 24 of file inspircd.h.

#define DllExport
 

Definition at line 23 of file inspircd.h.

#define ERROR   -1
 

Returned by some functions to indicate failure.

Definition at line 65 of file inspircd.h.

Referenced by InspSocket::InspSocket(), and irc::sockets::OpenTCPSocket().

#define ETIREDHAMSTERS   EAGAIN
 

Support for librodent - see http://www.chatspike.net/index.php?z=64.

Definition at line 70 of file inspircd.h.

#define IS_SINGLE x,
 )     ( (*x == y) && (*(x+1) == 0) )
 

This define is used in place of strcmp when we want to check if a char* string contains only one letter.

Pretty fast, its just two compares and an addition.

Definition at line 89 of file inspircd.h.

#define PATH_MAX   4096
 

Definition at line 60 of file inspircd.h.

Referenced by ServerConfig::GetFullProgDir().

#define printf_c   printf
 

Definition at line 25 of file inspircd.h.

Referenced by InspIRCd::DaemonSeed(), InspIRCd::LoadAllModules(), and InspIRCd::Start().


Typedef Documentation

typedef std::map<irc::string, unsigned int> clonemap
 

A list of ip addresses cross referenced against clone counts.

Definition at line 316 of file inspircd.h.

typedef std::vector<std::pair<std::string, std::string> > FailedPortList
 

A list of failed port bindings, used for informational purposes on startup.

Definition at line 313 of file inspircd.h.


Enumeration Type Documentation

enum DebugLevel
 

Debug levels for use with InspIRCd::Log().

Enumerator:
DEBUG 
VERBOSE 
DEFAULT 
SPARSE 
NONE 

Definition at line 74 of file inspircd.h.

00075 {
00076         DEBUG           =       10,
00077         VERBOSE         =       20,
00078         DEFAULT         =       30,
00079         SPARSE          =       40,
00080         NONE            =       50
00081 };


Function Documentation

template<typename T>
std::string ConvNumeric const T &  in  )  [inline]
 

Template function to convert any input type to std::string.

Definition at line 101 of file inspircd.h.

References MAXBUF.

Referenced by ConvToStr().

00102 {
00103         if (in == 0) return "0";
00104         char res[MAXBUF];
00105         char* out = res;
00106         T quotient = in;
00107         while (quotient) {
00108                 *out = "0123456789"[ std::abs( (long)quotient % 10 ) ];
00109                 ++out;
00110                 quotient /= 10;
00111         }
00112         if ( in < 0)
00113                 *out++ = '-';
00114         *out = 0;
00115         std::reverse(res,out);
00116         return res;
00117 }

template<typename T>
long ConvToInt const T &  in  )  [inline]
 

Template function to convert any input type to any other type (usually an integer or numeric type).

Definition at line 173 of file inspircd.h.

Referenced by TreeSocket::AddLine(), irc::tokenstream::GetToken(), and TreeSocket::IntroduceClient().

00174 {
00175         std::stringstream tmp;
00176         if (!(tmp << in)) return 0;
00177         return atoi(tmp.str().c_str());
00178 }

template<class T>
std::string ConvToStr const T &  in  )  [inline]
 

Template function to convert any input type to std::string.

Definition at line 163 of file inspircd.h.

00164 {
00165         std::stringstream tmp;
00166         if (!(tmp << in)) return std::string();
00167         return tmp.str();
00168 }

std::string ConvToStr char  in  )  [inline]
 

Template function to convert any input type to std::string.

Definition at line 156 of file inspircd.h.

00157 {
00158         return std::string(in,1);
00159 }

std::string ConvToStr const bool  in  )  [inline]
 

Template function to convert any input type to std::string.

Definition at line 149 of file inspircd.h.

00150 {
00151         return (in ? "1" : "0");
00152 }

std::string ConvToStr const char *  in  )  [inline]
 

Template function to convert any input type to std::string.

Definition at line 142 of file inspircd.h.

00143 {
00144         return in;
00145 }

std::string ConvToStr const unsigned long  in  )  [inline]
 

Template function to convert any input type to std::string.

Definition at line 135 of file inspircd.h.

References ConvNumeric().

00136 {
00137         return ConvNumeric(in);
00138 }

std::string ConvToStr const long  in  )  [inline]
 

Template function to convert any input type to std::string.

Definition at line 128 of file inspircd.h.

References ConvNumeric().

00129 {
00130         return ConvNumeric(in);
00131 }

std::string ConvToStr const int  in  )  [inline]
 

Template function to convert any input type to std::string.

Definition at line 121 of file inspircd.h.

References ConvNumeric().

Referenced by cmd_watch::add_watch(), userrec::AddClient(), ModuleFilterPCRE::AddFilter(), InspIRCd::BindPorts(), ModuleSpanningTree::BroadcastTimeSync(), TreeSocket::Capab(), chanrec::ChanModes(), TreeSocket::DoBurst(), ModuleAlias::DoCommand(), SQLConnection::DoLeadingQuery(), DoStats(), InspIRCd::Exit(), chanrec::GetModeParameter(), cmd_whowas::GetStats(), QueryInfo::Go(), cmd_rsquit::Handle(), cmd_taxonomy::Handle(), cmd_setidle::Handle(), cmd_jumpserver::Handle(), cmd_cycle::Handle(), cmd_close::Handle(), cmd_clones::Handle(), cmd_check::Handle(), cmd_alltime::Handle(), cmd_nick::Handle(), cmd_die::Handle(), TreeSocket::IntroduceClient(), ModuleSpanningTree::MapOperInfo(), NickFlood::ModeSet(), MsgFlood::ModeSet(), JoinFlood::ModeSet(), cmd_rsquit::NoticeUser(), Modulewatch::On005Numeric(), ModuleSilence::On005Numeric(), ModuleTestClient::OnBackgroundTimer(), ModuleSpanningTree::OnEvent(), ModuleSpanningTree::OnMode(), NickFlood::OnModeChange(), MsgFlood::OnModeChange(), KickRejoin::OnModeChange(), JoinFlood::OnModeChange(), ModuleOverride::OnPostCommand(), Modulewatch::OnPostConnect(), ModuleSSLOpenSSL::OnRehash(), ModuleSSLGnuTLS::OnRehash(), ModuleSpanningTree::OnStats(), ModuleZLib::OnStats(), ModuleSVSHold::OnStats(), ModuleFilterPCRE::OnStats(), ModuleFilter::OnStats(), ModuleDNSBL::OnStats(), ModuleCBan::OnStats(), ModuleSpanningTree::OnUserJoin(), Modulewatch::OnUserPostNick(), SQLquery::operator%(), SQLquery::operator,(), TreeSocket::ProcessLine(), ModuleSpanningTree::ProtoSendMode(), TreeSocket::SendCapabilities(), TreeSocket::SendFJoins(), HttpServerSocket::SendHeaders(), SQLConn::SQLConn(), XLineManager::stats_e(), XLineManager::stats_g(), XLineManager::stats_k(), XLineManager::stats_q(), XLineManager::stats_z(), TreeSocket::Time(), ModuleSpanningTree::TimeToStr(), ModuleSSLOpenSSL::VerifyCertificate(), and ModuleSSLGnuTLS::VerifyCertificate().

00122 {
00123         return ConvNumeric(in);
00124 }

template<typename T>
void DELETE T *  x  )  [inline]
 

Delete a pointer, and NULL its value.

Definition at line 93 of file inspircd.h.

Referenced by userrec::AddClient(), cmd_whowas::AddToWhoWas(), BanRedirect::BeforeMode(), ModuleSQLite3::ClearAllConnections(), ModulePgSQL::ClearAllConnections(), ClearAllConnections(), ModuleSQLite3::ClearOldConnections(), ModulePgSQL::ClearOldConnections(), ClearOldConnections(), TimerManager::DelTimer(), InspIRCd::EraseModule(), TreeSocket::ForceMode(), PgSQLresult::Free(), cmd_swhois::Handle(), cmd_silence::Handle(), cmd_dccallow::Handle(), cmd_title::Handle(), ModuleSafeList::HandleList(), chanrec::JoinUser(), ModuleOpermotd::LoadOperMOTD(), cmd_whowas::MaintainWhoWas(), ModuleTimedBans::OnBackgroundTimer(), ModuleSafeList::OnBufferFlushed(), ModuleNickFlood::OnChannelDelete(), ModuleMsgFlood::OnChannelDelete(), ModuleKickNoRejoin::OnChannelDelete(), ModuleJoinFlood::OnChannelDelete(), ModuleSWhois::OnCleanup(), ModuleSafeList::OnCleanup(), ModuleCustomTitle::OnCleanup(), ModuleBlockAmsg::OnCleanup(), ModuleBanRedirect::OnCleanup(), NickFlood::OnModeChange(), MsgFlood::OnModeChange(), KickRejoin::OnModeChange(), JoinFlood::OnModeChange(), ModuleSWhois::OnPostCommand(), ModuleSSLOpenSSL::OnPostConnect(), ModuleSSLGnuTLS::OnPostConnect(), ModuleXMLSocket::OnRehash(), ModuleVHost::OnRehash(), ModuleSWhois::OnRehash(), ModuleSSLOpenSSL::OnRehash(), ModuleSSLGnuTLS::OnRehash(), ModuleSecureList::OnRehash(), ModuleOverride::OnRehash(), ModuleModesOnOper::OnRehash(), ModuleOperLevels::OnRehash(), ModuleOperjoin::OnRehash(), ModuleInvisible::OnRehash(), ModuleHostChange::OnRehash(), ModuleFilter::OnRehash(), ModuleDenyChannels::OnRehash(), ModuleModesOnConnect::OnRehash(), ModuleConnJoin::OnRehash(), ModuleChanProtect::OnRehash(), ModuleCensor::OnRehash(), ModuleKickNoRejoin::OnUserPreJoin(), ModuleSWhois::OnUserQuit(), ModuleSilence::OnUserQuit(), ModuleDCCAllow::OnUserQuit(), ModuleCustomTitle::OnUserQuit(), cmd_whowas::PruneWhoWas(), userrec::PurgeEmptyChannels(), ModuleRestrictChans::ReadConfig(), SpanningTreeUtilities::ReadConfiguration(), ModulePgSQL::ReconnectConn(), TreeSocket::Squit(), RequestTimeout::Tick(), TimerManager::TickTimers(), TreeServer::Tidy(), cmd_whowas::~cmd_whowas(), ConfigReader::~ConfigReader(), ModuleAuditorium::~ModuleAuditorium(), ModuleBanException::~ModuleBanException(), ModuleBanRedirect::~ModuleBanRedirect(), ModuleBlockCAPS::~ModuleBlockCAPS(), ModuleBlockColour::~ModuleBlockColour(), ModuleBotMode::~ModuleBotMode(), ModuleCensor::~ModuleCensor(), ModuleChanFilter::~ModuleChanFilter(), ModuleChanProtect::~ModuleChanProtect(), ModuleCloaking::~ModuleCloaking(), ModuleDeaf::~ModuleDeaf(), ModuleDenyChannels::~ModuleDenyChannels(), ModuleHelpop::~ModuleHelpop(), ModuleHideChans::~ModuleHideChans(), ModuleHideOper::~ModuleHideOper(), ModuleHostChange::~ModuleHostChange(), ModuleInvisible::~ModuleInvisible(), ModuleInviteException::~ModuleInviteException(), ModuleJoinFlood::~ModuleJoinFlood(), ModuleKickNoRejoin::~ModuleKickNoRejoin(), ModuleKnock::~ModuleKnock(), ModuleModesOnConnect::~ModuleModesOnConnect(), ModuleModesOnOper::~ModuleModesOnOper(), ModuleMsgFlood::~ModuleMsgFlood(), ModuleNickFlood::~ModuleNickFlood(), ModuleNoCTCP::~ModuleNoCTCP(), ModuleNoInvite::~ModuleNoInvite(), ModuleNoKicks::~ModuleNoKicks(), ModuleNoNickChange::~ModuleNoNickChange(), ModuleNoNotice::~ModuleNoNotice(), ModuleOperChans::~ModuleOperChans(), ModuleOperLevels::~ModuleOperLevels(), ModulePrivacyMode::~ModulePrivacyMode(), ModuleRandQuote::~ModuleRandQuote(), ModuleRedirect::~ModuleRedirect(), ModuleServices::~ModuleServices(), ModuleServicesAccount::~ModuleServicesAccount(), ModuleShowwhois::~ModuleShowwhois(), ModuleSQL::~ModuleSQL(), ModuleSSLModes::~ModuleSSLModes(), ModuleStripColor::~ModuleStripColor(), ModuleSWhois::~ModuleSWhois(), ModuleVHost::~ModuleVHost(), and PgSQLresult::~PgSQLresult().

00094 {
00095         delete x;
00096         x = NULL;
00097 }

template<typename T, typename V, typename R>
char* itoa const T &  in,
V *  res,
base
[inline]
 

Template function to convert integer to char, storing result in *res and also returning the pointer to res.

Based on Stuart Lowe's C/C++ Pages.

Parameters:
T input value
V result value
R base to convert to

Definition at line 186 of file inspircd.h.

00187 {
00188         if (base < 2 || base > 16) { *res = 0; return res; }
00189         char* out = res;
00190         int quotient = in;
00191         while (quotient) {
00192                 *out = "0123456789abcdef"[ std::abs( quotient % base ) ];
00193                 ++out;
00194                 quotient /= base;
00195         }
00196         if ( in < 0 && base == 10) *out++ = '-';
00197         std::reverse( res, out );
00198         *out = 0;
00199         return res;
00200 }