From 76ebc88ccd6fef0bf2d97b607829fb3466e273af Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 11 Aug 2006 09:23:46 +0000 Subject: extern time_t TIME -> InspIRCd::Time() git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4873 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/base.cpp | 2 -- src/channels.cpp | 4 +--- src/cmd_kline.cpp | 3 --- src/cmd_nick.cpp | 3 --- src/cmd_notice.cpp | 5 +---- src/cmd_oper.cpp | 3 --- src/cmd_privmsg.cpp | 5 +---- src/cmd_quit.cpp | 3 --- src/cmd_stats.cpp | 12 ++++-------- src/cmd_time.cpp | 6 ++---- src/cmd_topic.cpp | 5 +---- src/cmd_whois.cpp | 6 +----- src/command_parse.cpp | 4 +--- src/commands.cpp | 2 -- src/configreader.cpp | 2 -- src/helperfuncs.cpp | 9 ++++----- src/inspircd.cpp | 19 +++++++++++++++---- src/inspsocket.cpp | 2 -- src/mode.cpp | 2 -- src/modes/cmode_b.cpp | 4 +--- src/modes/cmode_h.cpp | 2 -- src/modes/cmode_o.cpp | 2 -- src/modes/cmode_v.cpp | 2 -- src/modules.cpp | 5 ----- src/modules/extra/m_pgsql.cpp | 2 -- src/modules/m_blockamsg.cpp | 3 --- src/modules/m_cban.cpp | 18 +++++------------- src/modules/m_connflood.cpp | 3 --- src/modules/m_httpd.cpp | 1 - src/modules/m_safelist.cpp | 4 ---- src/modules/m_securelist.cpp | 4 ---- src/socket.cpp | 2 -- src/userprocess.cpp | 2 -- src/users.cpp | 16 +++++++--------- src/xline.cpp | 16 ++++++---------- 35 files changed, 50 insertions(+), 133 deletions(-) (limited to 'src') diff --git a/src/base.cpp b/src/base.cpp index 4612c4a59..126e5b824 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -27,8 +27,6 @@ const int bitfields[] = {1,2,4,8,16,32,64,128}; const int inverted_bitfields[] = {~1,~2,~4,~8,~16,~32,~64,~128}; -extern time_t TIME; - bool Extensible::Shrink(const std::string &key) { /* map::size_type map::erase( const key_type& key ); diff --git a/src/channels.cpp b/src/channels.cpp index 5e06e529d..b72db32fc 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -38,8 +38,6 @@ using namespace std; #include "helperfuncs.h" #include "typedefs.h" -extern time_t TIME; - chanrec::chanrec(InspIRCd* Instance) : ServerInstance(Instance) { *name = *topic = *setby = *key = 0; @@ -238,7 +236,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo strlcpy(Ptr->name, cname,CHANMAX); Ptr->modes[CM_TOPICLOCK] = Ptr->modes[CM_NOEXTERNAL] = 1; - Ptr->created = TIME; + Ptr->created = Instance->Time(); *Ptr->topic = 0; strlcpy(Ptr->setby, user->nick,NICKMAX-1); Ptr->topicset = 0; diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp index 83501bed2..4cd114dad 100644 --- a/src/cmd_kline.cpp +++ b/src/cmd_kline.cpp @@ -31,9 +31,6 @@ #include "helperfuncs.h" #include "commands/cmd_kline.h" - -extern time_t TIME; - void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user) { if (pcnt >= 3) diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp index c4db7ba24..a7472bd95 100644 --- a/src/cmd_nick.cpp +++ b/src/cmd_nick.cpp @@ -28,9 +28,6 @@ #include "hashcomp.h" #include "commands/cmd_nick.h" - -extern time_t TIME; - void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) { char oldnick[NICKMAX]; diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp index 0a80bf57f..6882c8d35 100644 --- a/src/cmd_notice.cpp +++ b/src/cmd_notice.cpp @@ -28,15 +28,12 @@ #include "hashcomp.h" #include "commands/cmd_notice.h" - -extern time_t TIME; - void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) { userrec *dest; chanrec *chan; - user->idle_lastmsg = TIME; + user->idle_lastmsg = ServerInstance->Time(); if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) return; diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp index df615b503..e8654ea59 100644 --- a/src/cmd_oper.cpp +++ b/src/cmd_oper.cpp @@ -36,9 +36,6 @@ #include "command_parse.h" #include "commands/cmd_oper.h" - -extern time_t TIME; - bool OneOfMatches(const char* host, const char* ip, const char* hostlist) { std::stringstream hl(hostlist); diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp index 59a450fef..955bb9af3 100644 --- a/src/cmd_privmsg.cpp +++ b/src/cmd_privmsg.cpp @@ -25,15 +25,12 @@ #include "helperfuncs.h" #include "commands/cmd_privmsg.h" - -extern time_t TIME; - void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) { userrec *dest; chanrec *chan; - user->idle_lastmsg = TIME; + user->idle_lastmsg = ServerInstance->Time(); if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) return; diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp index 25397edcb..40c5df55b 100644 --- a/src/cmd_quit.cpp +++ b/src/cmd_quit.cpp @@ -34,9 +34,6 @@ #include "socketengine.h" #include "commands/cmd_quit.h" - -extern time_t TIME; - void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) { user_hash::iterator iter = ServerInstance->clientlist.find(user->nick); diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index 3ed8c8b9f..b3ae20a5e 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -41,10 +41,6 @@ #include "command_parse.h" #include "commands/cmd_stats.h" - - -extern time_t TIME; - void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user) { string_list values; @@ -110,7 +106,7 @@ void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_lis { if (*i->second->oper) { - results.push_back(sn+" 249 "+user->nick+" :"+i->second->nick+" ("+i->second->ident+"@"+i->second->dhost+") Idle: "+ConvToStr(TIME - i->second->idle_lastmsg)); + results.push_back(sn+" 249 "+user->nick+" :"+i->second->nick+" ("+i->second->ident+"@"+i->second->dhost+") Idle: "+ConvToStr(ServerInstance->Time() - i->second->idle_lastmsg)); idx++; } } @@ -213,7 +209,7 @@ void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_lis userrec* i = *n; if (ServerInstance->IsNick(i->nick)) { - results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(TIME - i->age)); + results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); } } } @@ -227,7 +223,7 @@ void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_lis userrec* i = *n; if (ServerInstance->IsNick(i->nick)) { - results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(TIME - i->age)); + results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); } } } @@ -236,7 +232,7 @@ void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_lis if (statschar == 'u') { time_t current_time = 0; - current_time = TIME; + current_time = ServerInstance->Time(); time_t server_uptime = current_time - ServerInstance->startup_time; struct tm* stime; stime = gmtime(&server_uptime); diff --git a/src/cmd_time.cpp b/src/cmd_time.cpp index c9d47b813..e5ed1c183 100644 --- a/src/cmd_time.cpp +++ b/src/cmd_time.cpp @@ -21,14 +21,12 @@ #include "helperfuncs.h" #include "commands/cmd_time.h" - -extern time_t TIME; - void cmd_time::Handle (const char** parameters, int pcnt, userrec *user) { struct tm* timeinfo; + time_t local = ServerInstance->Time(); - timeinfo = localtime(&TIME); + timeinfo = localtime(&local); char tms[26]; snprintf(tms,26,"%s",asctime(timeinfo)); diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp index dccdfcb3f..fd9f192ae 100644 --- a/src/cmd_topic.cpp +++ b/src/cmd_topic.cpp @@ -22,9 +22,6 @@ #include "commands/cmd_topic.h" #include "helperfuncs.h" - -extern time_t TIME; - void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) { chanrec* Ptr; @@ -86,7 +83,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) strlcpy(Ptr->topic,topic,MAXTOPIC-1); strlcpy(Ptr->setby,user->nick,NICKMAX-1); - Ptr->topicset = TIME; + Ptr->topicset = ServerInstance->Time(); Ptr->WriteChannel(user, "TOPIC %s :%s", Ptr->name, Ptr->topic); if (IS_LOCAL(user)) { diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp index 2ee5e8b49..c863d7998 100644 --- a/src/cmd_whois.cpp +++ b/src/cmd_whois.cpp @@ -22,10 +22,6 @@ #include "helperfuncs.h" #include "commands/cmd_whois.h" - - -extern time_t TIME; - const char* Spacify(char* n) { static char x[MAXBUF]; @@ -81,7 +77,7 @@ void do_whois(InspIRCd* ServerInstance, userrec* user, userrec* dest,unsigned lo if (!strcasecmp(user->server,dest->server)) { // idle time and signon line can only be sent if youre on the same server (according to RFC) - user->WriteServ("317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, abs((dest->idle_lastmsg)-TIME), dest->signon); + user->WriteServ("317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, abs((dest->idle_lastmsg)-ServerInstance->Time()), dest->signon); } else { diff --git a/src/command_parse.cpp b/src/command_parse.cpp index aaafe3e30..3c8af85c8 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -48,8 +48,6 @@ #define nspace __gnu_cxx -extern time_t TIME; - /* Special commands which may occur without registration of the user */ cmd_user* command_user; cmd_nick* command_nick; @@ -202,7 +200,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) if (user) { /* activity resets the ping pending timer */ - user->nping = TIME + user->pingmax; + user->nping = ServerInstance->Time() + user->pingmax; if (cm->second->flags_needed) { if (!user->IsModeSet(cm->second->flags_needed)) diff --git a/src/commands.cpp b/src/commands.cpp index 48d0745d5..e74d82010 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -51,8 +51,6 @@ extern InspIRCd* ServerInstance; -extern time_t TIME; - const long duration_m = 60; const long duration_h = duration_m * 60; const long duration_d = duration_h * 24; diff --git a/src/configreader.cpp b/src/configreader.cpp index e4f56421e..de46a1f29 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -26,8 +26,6 @@ #include "userprocess.h" #include "xline.h" -extern time_t TIME; - std::vector old_module_names, new_module_names, added_modules, removed_modules; ServerConfig::ServerConfig(InspIRCd* Instance) : ServerInstance(Instance) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 50d9b0631..6d4bcfe3e 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -43,8 +43,6 @@ #include "typedefs.h" #include "inspircd.h" -extern time_t TIME; - static char TIMESTR[26]; static time_t LAST = 0; @@ -75,13 +73,14 @@ void InspIRCd::Log(int level, const std::string &text) if ((level < ServerInstance->Config->LogLevel) && !ServerInstance->Config->forcedebug) return; - if (TIME != LAST) + if (ServerInstance->Time() != LAST) { - struct tm *timeinfo = localtime(&TIME); + time_t local = ServerInstance->Time(); + struct tm *timeinfo = localtime(&local); strlcpy(TIMESTR,asctime(timeinfo),26); TIMESTR[24] = ':'; - LAST = TIME; + LAST = ServerInstance->Time(); } if (ServerInstance->Config->log_file && ServerInstance->Config->writelog) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 42612fa2d..046b19f8c 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -76,8 +76,6 @@ int iterations = 0; insp_sockaddr client, server; socklen_t length; -time_t TIME = time(NULL), OLDTIME = time(NULL); - char lowermap[255]; void InspIRCd::AddServerName(const std::string &servername) @@ -219,8 +217,8 @@ InspIRCd::InspIRCd(int argc, char** argv) : ModCount(-1) this->Config = new ServerConfig(this); this->Start(); this->module_sockets.clear(); - this->startup_time = time(NULL); - srand(time(NULL)); + this->TIME = this->OLDTIME = this->startup_time = time(NULL); + srand(this->TIME); log(DEBUG,"*** InspIRCd starting up!"); if (!ServerConfig::FileExists(CONFIG_FILE)) { @@ -1039,3 +1037,16 @@ int InspIRCd::GetModuleCount() return this->ModCount; } +time_t InspIRCd::Time() +{ + return TIME; +} + +classbase::classbase() +{ + /* This is in here only to make use of ServerInstance + * without using an ugly extern + */ + this->age = ServerInstance->Time(); +} + diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index aa3b68ed5..c99dedf96 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -31,8 +31,6 @@ using irc::sockets::OpenTCPSocket; using irc::sockets::insp_inaddr; using irc::sockets::insp_sockaddr; -extern time_t TIME; - InspSocket::InspSocket(InspIRCd* SI) { this->state = I_DISCONNECTED; diff --git a/src/mode.cpp b/src/mode.cpp index 064396240..6ee841301 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -65,8 +65,6 @@ using namespace std; /* +n (notice mask - our implementation of snomasks) */ #include "modes/umode_n.h" -extern time_t TIME; - ModeHandler::ModeHandler(InspIRCd* Instance, char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly) : ServerInstance(Instance), mode(modeletter), n_params_on(parameters_on), n_params_off(parameters_off), list(listmode), m_type(type), oper(operonly) { diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp index f265c1094..d8f75220d 100644 --- a/src/modes/cmode_b.cpp +++ b/src/modes/cmode_b.cpp @@ -13,8 +13,6 @@ #include "hashcomp.h" #include "modes/cmode_b.h" -extern time_t TIME; - ModeChannelBan::ModeChannelBan(InspIRCd* Instance) : ModeHandler(Instance, 'b', 1, 1, true, MODETYPE_CHANNEL, false) { } @@ -91,7 +89,7 @@ std::string& ModeChannelBan::AddBan(userrec *user,std::string &dest,chanrec *cha } } - b.set_time = TIME; + b.set_time = ServerInstance->Time(); strlcpy(b.data,dest.c_str(),MAXBUF); if (*user->nick) { diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index 493d4f776..4b4730d52 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -14,8 +14,6 @@ #include "hashcomp.h" #include "modes/cmode_h.h" -extern time_t TIME; - ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(Instance, 'h', 1, 1, true, MODETYPE_CHANNEL, false) { } diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp index 528cd4ede..63588b456 100644 --- a/src/modes/cmode_o.cpp +++ b/src/modes/cmode_o.cpp @@ -14,8 +14,6 @@ #include "hashcomp.h" #include "modes/cmode_o.h" -extern time_t TIME; - ModeChannelOp::ModeChannelOp(InspIRCd* Instance) : ModeHandler(Instance, 'o', 1, 1, true, MODETYPE_CHANNEL, false) { } diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp index c834c47fd..26e176bc5 100644 --- a/src/modes/cmode_v.cpp +++ b/src/modes/cmode_v.cpp @@ -14,8 +14,6 @@ #include "hashcomp.h" #include "modes/cmode_v.h" -extern time_t TIME; - ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, 'v', 1, 1, true, MODETYPE_CHANNEL, false) { } diff --git a/src/modules.cpp b/src/modules.cpp index fc772c797..f04745008 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -45,11 +45,6 @@ #include "dns.h" #include "inspircd.h" -extern time_t TIME; -extern command_table cmdlist; - -class Server; - // version is a simple class for holding a modules version number Version::Version(int major, int minor, int revision, int build, int flags) diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index d30e826e5..0389ddcd5 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -44,8 +44,6 @@ * I can access the socket engine :\ */ -extern time_t TIME; - /* Forward declare, so we can have the typedef neatly at the top */ class SQLConn; /* Also needs forward declaration, as it's used inside SQLconn */ diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp index 38fed16d6..8c0aab795 100644 --- a/src/modules/m_blockamsg.cpp +++ b/src/modules/m_blockamsg.cpp @@ -29,9 +29,6 @@ /* $ModDesc: Attempt to block /amsg, at least some of the irritating mIRC scripts. */ -extern time_t TIME; - - enum BlockAction { IBLOCK_KILL, IBLOCK_KILLOPERS, IBLOCK_NOTICE, IBLOCK_NOTICEOPERS, IBLOCK_SILENT }; class BlockedMessage : public classbase diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index eba40ee0c..50fac3041 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -30,8 +30,6 @@ /* $ModDesc: Gives /cban, aka C:lines. Think Q:lines, for channels. */ - - class CBan : public classbase { public: @@ -50,12 +48,8 @@ public: } }; -std::string EncodeCBan(const CBan &ban); -CBan DecodeCBan(const std::string &data); bool CBanComp(const CBan &ban1, const CBan &ban2); -void ExpireBans(); -extern time_t TIME; typedef std::vector cbanlist; /* cbans is declared here, as our type is right above. Don't try move it. */ @@ -75,8 +69,6 @@ class cmd_cban : public command_t { /* syntax: CBAN #channel time :reason goes here */ /* 'time' is a human-readable timestring, like 2d3h2s. */ - - ExpireBans(); if(pcnt == 1) { @@ -85,7 +77,7 @@ class cmd_cban : public command_t { if (parameters[0] == iter->chname) { - unsigned long remaining = (iter->set_on + iter->length) - TIME; + unsigned long remaining = (iter->set_on + iter->length) - ServerInstance->Time(); user->WriteServ( "386 %s %s :Removed CBAN with %lu seconds left before expiry (%s)", user->nick, iter->chname.c_str(), remaining, iter->reason.c_str()); cbans.erase(iter); break; @@ -103,7 +95,7 @@ class cmd_cban : public command_t long length = duration(parameters[1]); std::string reason = (pcnt > 2) ? parameters[2] : "No reason supplied"; - cbans.push_back(CBan(parameters[0], user->nick, TIME, length, reason)); + cbans.push_back(CBan(parameters[0], user->nick, ServerInstance->Time(), length, reason)); std::sort(cbans.begin(), cbans.end(), CBanComp); @@ -157,7 +149,7 @@ class ModuleCBan : public Module { for(cbanlist::iterator iter = cbans.begin(); iter != cbans.end(); iter++) { - unsigned long remaining = (iter->set_on + iter->length) - TIME; + unsigned long remaining = (iter->set_on + iter->length) - ServerInstance->Time(); results.push_back(std::string(ServerInstance->Config->ServerName)+" 210 "+user->nick+" "+iter->chname.c_str()+" "+iter->set_by+" "+ConvToStr(iter->set_on)+" "+ConvToStr(iter->length)+" "+ConvToStr(remaining)+" :"+iter->reason); } } @@ -242,10 +234,10 @@ class ModuleCBan : public Module /* 0 == permanent, don't mess with them! -- w00t */ if (iter->length != 0) { - if (iter->set_on + iter->length <= TIME) + if (iter->set_on + iter->length <= ServerInstance->Time()) { log(DEBUG, "m_cban.so: Ban on %s expired, removing...", iter->chname.c_str()); - ServerInstance->WriteOpers("*** %li second CBAN on %s (%s) set %u seconds ago expired", iter->length, iter->chname.c_str(), iter->reason.c_str(), TIME - iter->set_on); + ServerInstance->WriteOpers("*** %li second CBAN on %s (%s) set %u seconds ago expired", iter->length, iter->chname.c_str(), iter->reason.c_str(), ServerInstance->Time() - iter->set_on); cbans.erase(iter); go_again = true; } diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp index bf05c272a..291074c98 100644 --- a/src/modules/m_connflood.cpp +++ b/src/modules/m_connflood.cpp @@ -26,9 +26,6 @@ using namespace std; /* $ModDesc: Connection throttle */ int conns = 0, throttled = 0; -extern time_t TIME; - - class ModuleConnFlood : public Module { diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 1afa3bd09..c433553be 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -32,7 +32,6 @@ class ModuleHttp; static ModuleHttp* HttpModule; -extern time_t TIME; static bool claimed; enum HttpState diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index bc0b8bf3d..ef8065637 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -24,10 +24,6 @@ using namespace std; #include "configreader.h" #include "inspircd.h" -extern time_t TIME; - - - class ListData : public classbase { public: diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index dad59b6e3..1e65fcce0 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -23,12 +23,8 @@ using namespace std; #include #include "inspircd.h" -extern time_t TIME; - /* $ModDesc: A module overriding /list, and making it safe - stop those sendq problems. */ - - class ModuleSecureList : public Module { private: diff --git a/src/socket.cpp b/src/socket.cpp index 2e54da2ce..0509f4bf3 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -23,8 +23,6 @@ #include "socketengine.h" #include "wildcard.h" -extern time_t TIME; - using namespace std; using namespace irc::sockets; diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 4d0f38b7c..ccd32a9c9 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -54,8 +54,6 @@ using namespace std; extern struct sockaddr_in client,server; extern socklen_t length; -extern time_t TIME; -extern time_t OLDTIME; char data[65536]; void InspIRCd::ProcessUser(userrec* cu) diff --git a/src/users.cpp b/src/users.cpp index b1378260d..4529a3484 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -31,8 +31,6 @@ #include "xline.h" #include "cull_list.h" -extern time_t TIME; - irc::whowas::whowas_users whowas; static unsigned long already_sent[MAX_DESCRIPTORS] = {0}; @@ -255,7 +253,7 @@ userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance) // the PROPER way to do it, AVOID bzero at *ALL* costs *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = 0; server = (char*)Instance->FindServerNamePtr(Instance->Config->ServerName); - reset_due = TIME; + reset_due = ServerInstance->Time(); lines_in = fd = lastping = signon = idle_lastmsg = nping = registered = 0; timeout = flood = bytes_in = bytes_out = cmds_in = cmds_out = 0; haspassed = dns_done = false; @@ -742,14 +740,14 @@ namespace irc } /* every hour, run this function which removes all entries over 3 days */ - void MaintainWhoWas(time_t TIME) + void MaintainWhoWas(time_t t) { for (whowas_users::iterator iter = ::whowas.begin(); iter != ::whowas.end(); iter++) { whowas_set* n = (whowas_set*)iter->second; if (n->size()) { - while ((n->begin() != n->end()) && ((*n->begin())->signon < TIME - 259200)) // 3 days + while ((n->begin() != n->end()) && ((*n->begin())->signon < t - 259200)) // 3 days { WhoWasGroup *a = *(n->begin()); DELETE(a); @@ -826,7 +824,7 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, strcpy(_new->ident, "unknown"); _new->registered = REG_NONE; - _new->signon = TIME + Instance->Config->dns_timeout; + _new->signon = Instance->Time() + Instance->Config->dns_timeout; _new->lastping = 1; log(DEBUG,"Setting socket addresses"); @@ -859,8 +857,8 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, } } - _new->nping = TIME + _new->pingmax + Instance->Config->dns_timeout; - _new->timeout = TIME+class_regtimeout; + _new->nping = Instance->Time() + _new->pingmax + Instance->Config->dns_timeout; + _new->timeout = Instance->Time() + class_regtimeout; _new->flood = class_flood; _new->threshold = class_threshold; _new->sendqmax = class_sqmax; @@ -962,7 +960,7 @@ long userrec::LocalCloneCount() void userrec::FullConnect(CullList* Goners) { ServerInstance->stats->statsConnects++; - this->idle_lastmsg = TIME; + this->idle_lastmsg = ServerInstance->Time(); ConnectClass a = this->GetClass(); diff --git a/src/xline.cpp b/src/xline.cpp index 64a5c93a6..6e40180ff 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -58,10 +58,6 @@ extern InspIRCd* ServerInstance; * -- Brain */ - - -extern time_t TIME; - /* Lists for temporary lines with an expiry time */ std::vector klines; @@ -153,7 +149,7 @@ bool add_gline(long duration, const char* source,const char* reason,const char* strlcpy(item.reason,reason,MAXBUF); strlcpy(item.source,source,255); item.n_matches = 0; - item.set_time = TIME; + item.set_time = ServerInstance->Time(); if (duration) { @@ -179,7 +175,7 @@ bool add_eline(long duration, const char* source, const char* reason, const char strlcpy(item.reason,reason,MAXBUF); strlcpy(item.source,source,255); item.n_matches = 0; - item.set_time = TIME; + item.set_time = ServerInstance->Time(); if (duration) { elines.push_back(item); @@ -204,7 +200,7 @@ bool add_qline(long duration, const char* source, const char* reason, const char strlcpy(item.source,source,255); item.n_matches = 0; item.is_global = false; - item.set_time = TIME; + item.set_time = ServerInstance->Time(); if (duration) { qlines.push_back(item); @@ -235,7 +231,7 @@ bool add_zline(long duration, const char* source, const char* reason, const char strlcpy(item.source,source,255); item.n_matches = 0; item.is_global = false; - item.set_time = TIME; + item.set_time = ServerInstance->Time(); if (duration) { zlines.push_back(item); @@ -259,7 +255,7 @@ bool add_kline(long duration, const char* source, const char* reason, const char strlcpy(item.reason,reason,MAXBUF); strlcpy(item.source,source,255); item.n_matches = 0; - item.set_time = TIME; + item.set_time = ServerInstance->Time(); if (duration) { klines.push_back(item); @@ -602,7 +598,7 @@ bool QSortComparison ( const QLine one, const QLine two ) void expire_lines() { - time_t current = TIME; + time_t current = ServerInstance->Time(); /* Because we now store all our XLines in sorted order using (i->duration + i->set_time) as a key, this * means that to expire the XLines we just need to do a while, picking off the top few until there are -- cgit v1.2.3