Data Structures | Functions | Variables

Anope Namespace Reference

Data Structures

class  string
struct  hash_ci
struct  hash_cs
struct  compare
class  map
class  hash_map
class  ascii_ctype
class  rfc1459_ctype

Functions

std::ostream & operator<< (std::ostream &os, const string &_str)
std::istream & operator>> (std::istream &is, string &_str)
const string operator+ (char chr, const string &str)
const string operator+ (const char *_str, const string &str)
const string operator+ (const std::string &_str, const string &str)
CoreExport string Version ()
CoreExport string VersionShort ()
CoreExport string VersionBuildString ()
CoreExport int VersionMajor ()
CoreExport int VersionMinor ()
CoreExport int VersionPatch ()
bool AtTerm ()
void Fork ()
void HandleSignal ()
void Init (int ac, char **av)
CoreExport void SaveDatabases ()
CoreExport bool Match (const string &str, const string &mask, bool case_sensitive=false, bool use_regex=false)
CoreExport string Hex (const string &data)
CoreExport string Hex (const char *data, unsigned len)
CoreExport void Unhex (const string &src, string &dest)
CoreExport void Unhex (const string &src, char *dest, size_t sz)
CoreExport void B64Encode (const string &src, string &target)
CoreExport void B64Decode (const string &src, string &target)
CoreExport void Encrypt (const Anope::string &src, Anope::string &dest)
CoreExport bool Decrypt (const Anope::string &src, Anope::string &dest)
CoreExport string printf (const char *fmt,...)
CoreExport int LastErrorCode ()
CoreExport const string LastError ()
CoreExport bool IsFile (const Anope::string &file)
CoreExport time_t DoTime (const Anope::string &s)
CoreExport Anope::string Duration (time_t seconds, const NickCore *nc=NULL)
CoreExport Anope::string Expires (time_t seconds, const NickCore *nc=NULL)
CoreExport Anope::string strftime (time_t t, const NickCore *nc=NULL, bool short_output=false)
CoreExport Anope::string NormalizeBuffer (const Anope::string &)
void Process (const Anope::string &)
Anope::string Resolve (const Anope::string &host, int type)

Variables

static const char *const compiled = " " __DATE__
CoreExport time_t StartTime = time(NULL)
int ReturnValue = 0
sig_atomic_t Signal = 0
CoreExport bool Quitting = false
CoreExport bool Restarting = false
CoreExport Anope::string QuitReason
CoreExport time_t CurTime = time(NULL)
CoreExport int Debug = 0
CoreExport bool ReadOnly = false
CoreExport bool NoFork = false
CoreExport bool NoThird = false
CoreExport bool NoExpire = false
CoreExport bool ProtocolDebug = false
CoreExport Anope::string ServicesDir
CoreExport Anope::string ServicesBin
CoreExport Anope::string ConfigDir = "conf"
CoreExport Anope::string DataDir = "data"
CoreExport Anope::string ModuleDir = "lib"
CoreExport Anope::string LocaleDir = "locale"
CoreExport Anope::string LogDir = "logs"
CoreExport int CurrentUplink = -1
std::locale casemap = std::locale(std::locale(), new Anope::ascii_ctype<char>())

Function Documentation

bool Anope::AtTerm (  ) 

Determines if we are still attached to the terminal, and can print messages to the user via stderr/stdout.

Returns:
true if still attached

Definition at line 93 of file init.cpp.

Referenced by Init(), Server::Sync(), and UplinkSocket::~UplinkSocket().

void Anope::B64Decode ( const string &  src,
Anope::string target 
)

Base 64 decode a string

Parameters:
src The base64 encoded string
target The plain text result

Definition at line 123 of file base64.cpp.

References Anope::string::begin(), Anope::string::clear(), Anope::string::end(), Anope::string::erase(), Anope::string::find(), Anope::string::length(), Anope::string::npos, and Pad64.

Referenced by ENone::OnDecrypt(), IRCDMessageSASL::Run(), IRCDMessageNick::Run(), and IRCDMessageEncap::Run().

void Anope::B64Encode ( const string &  src,
Anope::string target 
)

Base 64 encode a string

Parameters:
src The string to encode
target Where the encoded string is placed

Definition at line 82 of file base64.cpp.

References Anope::string::clear(), Anope::string::length(), and Pad64.

Referenced by ENone::OnEncrypt().

bool Anope::Decrypt ( const Anope::string src,
Anope::string dest 
)

Decrypts what is in 'src' to 'dest'.

Parameters:
src The source string to decrypt
dest The destination where the decrypted string is placed
Returns:
true if decryption was successful. This is usually not the case as most encryption methods we use are one way.

Definition at line 469 of file misc.cpp.

References Anope::string::begin(), EVENT_ALLOW, Anope::string::find(), FOREACH_RESULT, hashm, I_OnDecrypt, and Anope::string::npos.

Referenced by CommandNSSASetPassword::Execute(), CommandNSSetPassword::Execute(), CommandNSRegister::Execute(), CommandNSGetPass::Execute(), and NSGetPass::NSGetPass().

time_t Anope::DoTime ( const Anope::string s  ) 
Anope::string Anope::Duration ( time_t  seconds,
const NickCore nc = NULL 
)

Retrieves a human readable string representing the time in seconds

Parameters:
seconds The time on seconds, eg 60
nc The account to use langauge settings for to translate this string, if applicable
Returns:
A human readable string, eg "1 minute"

Definition at line 269 of file misc.cpp.

References _, stringify(), and Language::Translate().

Referenced by CommandOSAKill::DoAdd(), CommandOSStats::DoStatsUptime(), CommandNSRegister::Execute(), CommandSeen::Execute(), CommandCSBan::Execute(), CommandOSSQLine::OnAdd(), CommandOSSNLine::OnAdd(), NickServCore::OnNickIdentify(), strftime(), and MyNickServService::Validate().

void Anope::Encrypt ( const Anope::string src,
Anope::string dest 
)

Encrypts what is in 'src' to 'dest'

Parameters:
src The source string to encrypt
dest The destination where the encrypted string is placed

Definition at line 463 of file misc.cpp.

References FOREACH_RESULT, and I_OnEncrypt.

Referenced by CommandNSSASetPassword::Execute(), CommandNSSetPassword::Execute(), CommandNSRegister::Execute(), ESHA256::OnCheckAuthentication(), ESHA1::OnCheckAuthentication(), EOld::OnCheckAuthentication(), ENone::OnCheckAuthentication(), EMD5::OnCheckAuthentication(), and IdentifyInterface::OnResult().

Anope::string Anope::Expires ( time_t  seconds,
const NickCore nc = NULL 
)

Generates a human readable string of type "expires in ..."

Parameters:
expires time in seconds
nc The account to use langauge settings for to translate this string, if applicable
Returns:
A human readable string, eg "expires in 5 days"

Definition at line 323 of file misc.cpp.

References _, CurTime, NO_EXPIRE, and Language::Translate().

Referenced by WebCPanel::OperServ::Akill::OnRequest(), CommandOSSXLineBase::ProcessList(), and CommandOSAKill::ProcessList().

void Anope::Fork (  ) 

Used to "fork" the process and go into the background during initial startup while we are AtTerm(). The actual fork is not done here, but earlier, and this simply notifys the parent via kill() to exit().

Definition at line 98 of file init.cpp.

Referenced by Server::Sync().

void Anope::HandleSignal (  ) 

Does something with the signal in Anope::Signal

Definition at line 113 of file init.cpp.

References Config, FOREACH_MOD, CoreException::GetReason(), I_OnReload, QuitReason, Quitting, SaveDatabases(), SIGHUP, Signal, and stringify().

Referenced by main().

Anope::string Anope::Hex ( const char *  data,
unsigned  len 
)

Definition at line 512 of file misc.cpp.

Anope::string Anope::Hex ( const string &  data  ) 

Converts a string to hex

Parameters:
the data to be converted
Returns:
a anope::string containing the hex value

Definition at line 497 of file misc.cpp.

References Anope::string::length().

void Anope::Init ( int  ac,
char **  av 
)
bool Anope::IsFile ( const Anope::string file  ) 
const Anope::string Anope::LastError (  ) 
int Anope::LastErrorCode (  ) 

Return the last error code

Returns:
The error code

Definition at line 548 of file misc.cpp.

Referenced by SocketIO::Connect(), and SSLSocketIO::Connect().

bool Anope::Match ( const string &  str,
const string &  mask,
bool  case_sensitive = false,
bool  use_regex = false 
)

Check whether two strings match.

Parameters:
str The string to check against the pattern (e.g. foobar)
mask The pattern to check (e.g. foo*bar)
case_sensitive Whether or not the match is case sensitive, default false.
use_regex Whether or not to try regex. case_sensitive is not used in regex.

Definition at line 359 of file misc.cpp.

References Config, Regex::GetExpression(), CoreException::GetReason(), Anope::string::length(), LOG_DEBUG, Regex::Matches(), Anope::string::npos, ServerConfig::RegexEngine, and Anope::string::substr().

Referenced by LogInfo::AddType(), XLineManager::CanAdd(), SNLineManager::Check(), SQLineManager::Check(), SGLineManager::Check(), SQLineManager::CheckChannel(), CommandCSAKick::DoAdd(), CommandNSAccess::DoList(), XOPBase::DoList(), CommandCSFlags::DoList(), CommandBSBadwords::DoList(), CommandCSMode::DoSet(), RewriteCommand::Execute(), CommandOSLogSearch::Execute(), CommandOSUserList::Execute(), CommandOSChanList::Execute(), CommandNSList::Execute(), CommandHSList::Execute(), CommandCSList::Execute(), CommandCSKick::Execute(), CommandCSBan::Execute(), MySessionService::FindException(), ChannelInfo::GetMLock(), OperType::HasCommand(), MemoInfo::HasIgnore(), OperType::HasPriv(), LogInfo::HasType(), NickCore::IsOnAccess(), User::IsServicesOper(), Entry::Matches(), UnrealExtBan::Matches(), InspIRCdExtBan::Matches(), ChanAccess::Matches(), CommandOSSQLine::OnAdd(), CommandOSSNLine::OnAdd(), CommandOSSXLineBase::ProcessList(), CommandOSException::ProcessList(), CommandOSAKill::ProcessList(), CommandCSAKick::ProcessList(), CommandCSAccess::ProcessList(), Channel::RemoveModeInternal(), IRCDMessageEncap::Run(), and Channel::SetCorrectModes().

Anope::string Anope::NormalizeBuffer ( const Anope::string buf  ) 

Normalize buffer, stripping control characters and colors

Parameters:
A string to be parsed for control and color codes
Returns:
A string stripped of control and color codes

Definition at line 615 of file misc.cpp.

References Anope::string::length().

Referenced by BSKick::OnPrivmsg(), and IRCDProto::SendCTCPInternal().

const string Anope::operator+ ( const char *  _str,
const string &  str 
) [inline]

Definition at line 308 of file anope.h.

const string Anope::operator+ ( const std::string &  _str,
const string &  str 
) [inline]

Definition at line 309 of file anope.h.

const string Anope::operator+ ( char  chr,
const string &  str 
) [inline]

Definition at line 307 of file anope.h.

std::ostream& Anope::operator<< ( std::ostream &  os,
const string &  _str 
) [inline]

Stream insertion operator, must be friend because they cannot be inside the class.

Definition at line 303 of file anope.h.

References Anope::string::_string.

std::istream& Anope::operator>> ( std::istream &  is,
string &  _str 
) [inline]

Definition at line 305 of file anope.h.

References Anope::string::_string.

Anope::string Anope::printf ( const char *  fmt,
  ... 
)

Returns a sequence of data formatted as the format argument specifies. After the format parameter, the function expects at least as many additional arguments as specified in format.

Parameters:
fmt Format of the Message
... any number of parameters
Returns:
a Anope::string

Definition at line 487 of file misc.cpp.

Referenced by CommandNSSetPrivate::CommandNSSetPrivate(), CommandOSLogin::CommandOSLogin(), CommandOSLogout::CommandOSLogout(), CommandOSSXLineBase::CommandOSSXLineBase(), CommandCSMode::DoLock(), CommandOSDefcon::Execute(), CommandNSList::Execute(), CommandHSReject::Execute(), CommandSeen::Execute(), CommandCSInfo::Execute(), CommandBSInfo::Execute(), cidr::mask(), req_send_memos(), rsend_notify(), strftime(), and DefConTimeout::Tick().

void Anope::Process ( const Anope::string buffer  ) 
Anope::string Anope::Resolve ( const Anope::string host,
int  type 
)

Does a blocking dns query and returns the first IP.

Parameters:
host host to look up
type inet addr type
Returns:
the IP if it was found, else the host

Definition at line 681 of file misc.cpp.

References sockaddrs::addr(), Anope::string::c_str(), and LOG_DEBUG_2.

Referenced by Uplink::Connect().

void Anope::SaveDatabases (  ) 
Anope::string Anope::strftime ( time_t  t,
const NickCore nc = NULL,
bool  short_output = false 
)

Converts a time in seconds (epoch) to a human readable format.

Parameters:
t The time
nc The account to use langauge settings for to translate this string, if applicable
short_output If true, the output is just a date (eg, "Apr 12 20:18:22 2009 MSD"), else it includes the date and how long ago/from now that date is, (eg "Apr 12 20:18:22 2009 MSD (1313 days, 9 hours, 32 minutes ago)"

Definition at line 310 of file misc.cpp.

References _, CurTime, Duration(), printf(), and Language::Translate().

Referenced by alog(), BuildDate(), CreateLogName(), CommandOSLogSearch::CreateLogName(), OSNews::DisplayNews(), NewsBase::DoList(), CommandOSIgnore::DoList(), CommandHSWaiting::DoList(), CommandCSFlags::DoList(), CommandEntryMessage::DoList(), CommandCSMode::DoLock(), MemoListCallback::DoRead(), CommandOSStats::DoStatsUptime(), CommandOSModInfo::Execute(), CommandOSForbid::Execute(), CommandNSSuspend::Execute(), CommandNSInfo::Execute(), CommandNSGList::Execute(), CommandMSList::Execute(), CommandMSCheck::Execute(), CommandHSList::Execute(), CommandCSSuspend::Execute(), CommandSeen::Execute(), CommandOSSeen::Execute(), CommandCSInfo::Execute(), CommandBSInfo::Execute(), get_logname(), GetTimeStamp(), WebCPanel::OperServ::Akill::OnRequest(), WebCPanel::MemoServ::Memos::OnRequest(), WebCPanel::ChanServ::Set::OnRequest(), WebCPanel::NickServ::Info::OnRequest(), CommandOSSXLineBase::ProcessList(), CommandOSException::ProcessList(), CommandOSAKill::ProcessList(), CommandCSAKick::ProcessList(), CommandCSAccess::ProcessList(), Message::Time::Run(), and DataBasePurger::Tick().

void Anope::Unhex ( const string &  src,
Anope::string dest 
)

Converts a string from hex

Parameters:
src The data to be converted
dest The destination string

Definition at line 526 of file misc.cpp.

References casemap, and Anope::string::length().

Referenced by ESHA256::GetIVFromPass(), Unhex(), and HTTPUtils::URLDecode().

void Anope::Unhex ( const string &  src,
char *  dest,
size_t  sz 
)

Definition at line 540 of file misc.cpp.

References Anope::string::c_str(), Anope::string::length(), and Unhex().

Anope::string Anope::Version (  ) 

Various methods to determine the Anope version running

Definition at line 576 of file misc.cpp.

References stringify().

Referenced by Init(), Module::Module(), Message::Privmsg::Run(), InspIRCd12Proto::SendConnect(), and InspIRCdProto::SendConnect().

Anope::string Anope::VersionBuildString (  ) 
int Anope::VersionMajor (  ) 

Definition at line 611 of file misc.cpp.

Referenced by ModuleManager::LoadModule(), and ModuleManager::RequireVersion().

int Anope::VersionMinor (  ) 

Definition at line 612 of file misc.cpp.

Referenced by ModuleManager::LoadModule(), and ModuleManager::RequireVersion().

int Anope::VersionPatch (  ) 

Definition at line 613 of file misc.cpp.

Referenced by ModuleManager::LoadModule(), and ModuleManager::RequireVersion().

Anope::string Anope::VersionShort (  ) 

Variable Documentation

std::locale Anope::casemap = std::locale(std::locale(), new Anope::ascii_ctype<char>())
const char* const Anope::compiled = " " __DATE__ [static]

Definition at line 338 of file anope.h.

Referenced by VersionBuildString().

Various directory paths. These can be set at runtime by command line args

Definition at line 28 of file init.cpp.

Referenced by ConfigurationFile::Open().

time_t Anope::CurTime = time(NULL)

The current system time, which is pretty close to being accurate. Use this unless you need very specific time checks

Definition at line 41 of file main.cpp.

Referenced by ChannelInfo::AccessFor(), OSSession::AddSession(), DBPlain::BackupDatabase(), DBFlatFile::BackupDatabase(), User::BadPassword(), ProxyConnect::Ban(), BotInfo::BotInfo(), BuildDate(), User::ChangeNick(), Channel::ChangeTopic(), Channel::ChangeTopicInternal(), ChannelInfo::ChannelInfo(), XLineManager::CheckAllXLines(), MyManager::CheckCache(), DBMySQL::CheckSQL(), UserData::Clear(), User::Collide(), CommandOSException::DoAdd(), NewsBase::DoAdd(), CommandOSAKill::DoAdd(), XOPBase::DoAdd(), CommandCSAccess::DoAdd(), CommandOSIgnore::DoList(), CommandCSFlags::DoModify(), MyXMLRPCEvent::DoStats(), CommandOSStats::DoStatsUptime(), CommandOSSVSNick::Execute(), CommandOSLogSearch::Execute(), CommandOSForbid::Execute(), CommandOSChanKill::Execute(), CommandNSUpdate::Execute(), CommandNSSuspend::Execute(), CommandNSResend::Execute(), CommandNSRegister::Execute(), CommandNSGroup::Execute(), CommandHSRequest::Execute(), CommandCSSuspend::Execute(), CommandSeen::Execute(), CommandOSSeen::Execute(), CommandCSLog::Execute(), CommandBSAct::Execute(), CommandBSSay::Execute(), Expires(), GetTimeStamp(), User::Identify(), Serializable::IsTSCached(), User::KillInternal(), LoadChannels(), main(), Module::Module(), NickAlias::NickAlias(), CommandOSSQLine::OnAdd(), CommandOSSNLine::OnAdd(), CSAKick::OnCheckKick(), OnDatabaseReadMetadata(), ModuleDNS::OnDnsRequest(), BotServCore::OnJoinChannel(), OSForbid::OnJoinChannel(), CSLog::OnLog(), DNSBLResolver::OnLookupComplete(), NickServCore::OnNickIdentify(), CSSuspend::OnPreChanExpire(), NSResetPass::OnPreCommand(), NSSuspend::OnPreNickExpire(), ModuleDNS::OnPreUserLogoff(), BSKick::OnPrivmsg(), WebCPanel::ChanServ::Access::OnRequest(), DBMySQL::OnSerializeCheck(), NSRecoverRequest::OnSuccess(), NSGroupRequest::OnSuccess(), OSDefcon::OnUserConnect(), SocketEngine::Process(), LogInfo::ProcessMessage(), BanData::purge(), LDAPService::Reconnect(), Channel::RemoveMode(), ChannelInfo::RestoreTopic(), Message::Whois::Run(), Message::Topic::Run(), Message::Stats::Run(), Message::Quit::Run(), Message::Kill::Run(), Message::Join::Run(), IRCDMessageNetInfo::Run(), IRCDMessageUID::Run(), IRCDMessageChaninfo::Run(), IRCDMessageTime::Run(), IRCDMessageNick::Run(), IRCDMessageIdle::Run(), IRCDMessageFTopic::Run(), IRCDMessageFJoin::Run(), IRCDMessageTBurst::Run(), IRCDMessageTopic::Run(), IRCDMessageSJoin::Run(), DBSQL::RunBackground(), Mail::Send(), MyMemoServService::Send(), InspIRCd12Proto::SendAddLine(), UnrealIRCdProto::SendAkill(), ngIRCdProto::SendAkill(), InspIRCd12Proto::SendAkill(), InspIRCdProto::SendAkill(), HybridProto::SendAkill(), BahamutIRCdProto::SendAkill(), InspIRCd12Proto::SendBOB(), InspIRCdProto::SendBOB(), RatboxProto::SendConnect(), PlexusProto::SendConnect(), HybridProto::SendConnect(), BahamutIRCdProto::SendConnect(), IRCDProto::SendNickChange(), SendResetEmail(), InspIRCd12Proto::SendSQLine(), InspIRCdProto::SendSQLine(), HybridProto::SendSQLine(), UnrealIRCdProto::SendSVSHold(), HybridProto::SendSVSHold(), UnrealIRCdProto::SendSZLine(), InspIRCd12Proto::SendSZLine(), InspIRCdProto::SendSZLine(), HybridProto::SendSZLine(), BahamutIRCdProto::SendSZLine(), InspIRCd12Proto::SendTopic(), CommandCSTopic::Set(), Channel::SetMode(), Channel::SetModesInternal(), Timer::SetSecs(), Message::Join::SJoin(), strftime(), ExpireCallback::Tick(), ModuleProxyScan::ConnectionTimeout::Tick(), MyHTTPProvider::Tick(), ExpireTimer::Tick(), DataBasePurger::Tick(), MyManager::UpdateSerial(), Serializable::UpdateTS(), CSSeen::UpdateUser(), User::User(), MyNickServService::Validate(), and Server::~Server().

int Anope::Debug = 0

The debug level we are running at.

Definition at line 27 of file main.cpp.

Referenced by CommandOSSet::DoList(), CommandOSSet::DoSetDebug(), GetTimeStamp(), LogInfo::HasType(), Init(), Config::Config::Main(), and Log::~Log().

Definition at line 28 of file init.cpp.

Referenced by Init(), Language::InitLanguages(), and Module::Module().

Definition at line 28 of file init.cpp.

Referenced by CreateLogName(), CommandOSLogSearch::CreateLogName(), and Init().

Definition at line 28 of file init.cpp.

Referenced by Init(), and moduleCopyFile().

bool Anope::NoExpire = false
bool Anope::NoFork = false

Definition at line 28 of file main.cpp.

Referenced by Init(), Server::Sync(), and Log::~Log().

bool Anope::NoThird = false

Definition at line 28 of file main.cpp.

Referenced by Init(), and Module::Module().

bool Anope::ProtocolDebug = false

Definition at line 28 of file main.cpp.

Referenced by Init(), and Process().

bool Anope::Quitting = false
bool Anope::ReadOnly = false
bool Anope::Restarting = false

Definition at line 35 of file main.cpp.

Referenced by CommandOSRestart::Execute(), and main().

The value to return from main()

Definition at line 32 of file main.cpp.

Referenced by Init(), main(), parent_signal_handler(), and UplinkSocket::~UplinkSocket().

Services binary name (eg services)

Definition at line 30 of file main.cpp.

Referenced by Init().

The root of the services installation. Usually ~/services

Definition at line 29 of file main.cpp.

Referenced by Init().

sig_atomic_t Anope::Signal = 0

Definition at line 33 of file main.cpp.

Referenced by HandleSignal(), main(), and SignalHandler().

time_t Anope::StartTime = time(NULL)

The time Anope started.

Definition at line 40 of file main.cpp.

Referenced by MyXMLRPCEvent::DoStats(), CommandOSStats::DoStatsUptime(), Message::Stats::Run(), and IRCDMessageIdle::Run().