summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp2
-rw-r--r--src/cmd_list.cpp2
-rw-r--r--src/cmd_lusers.cpp22
-rw-r--r--src/cmd_notice.cpp3
-rw-r--r--src/cmd_privmsg.cpp3
-rw-r--r--src/cmd_quit.cpp5
-rw-r--r--src/cmd_restart.cpp4
-rw-r--r--src/cmd_stats.cpp5
-rw-r--r--src/command_parse.cpp1
-rw-r--r--src/commands.cpp1
-rw-r--r--src/helperfuncs.cpp74
-rw-r--r--src/inspircd.cpp8
-rw-r--r--src/modules.cpp18
-rw-r--r--src/modules/m_chanprotect.cpp2
-rw-r--r--src/modules/m_globops.cpp3
-rw-r--r--src/modules/m_helpop.cpp4
-rw-r--r--src/modules/m_override.cpp2
-rw-r--r--src/modules/m_park.cpp6
-rw-r--r--src/modules/m_redirect.cpp2
-rw-r--r--src/modules/m_safelist.cpp2
-rw-r--r--src/modules/m_spanningtree.cpp24
-rw-r--r--src/modules/m_spy.cpp2
-rw-r--r--src/userprocess.cpp7
-rw-r--r--src/users.cpp34
-rw-r--r--src/xline.cpp3
25 files changed, 105 insertions, 134 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index bf2596bb1..b9e88a5bd 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -325,7 +325,7 @@ chanrec* chanrec::JoinUser(userrec *user, const char* cn, bool override, const c
FOREACH_RESULT(I_OnCheckLimit,OnCheckLimit(user, Ptr));
if (!MOD_RESULT)
{
- if (usercount(Ptr) >= Ptr->limit)
+ if (Ptr->GetUserCounter() >= Ptr->limit)
{
user->WriteServ("471 %s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name);
return NULL;
diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp
index 26fa3cc10..3dbb3c2e2 100644
--- a/src/cmd_list.cpp
+++ b/src/cmd_list.cpp
@@ -32,7 +32,7 @@ void cmd_list::Handle (const char** parameters, int pcnt, userrec *user)
bool n = i->second->HasUser(user);
if (((!(i->second->modes[CM_PRIVATE])) && (!(i->second->modes[CM_SECRET]))) || (n))
{
- long users = usercount(i->second);
+ long users = i->second->GetUserCounter();
if (users)
user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,users,chanmodes(i->second,n),i->second->topic);
}
diff --git a/src/cmd_lusers.cpp b/src/cmd_lusers.cpp
index 9c35bf35a..acb43c7ce 100644
--- a/src/cmd_lusers.cpp
+++ b/src/cmd_lusers.cpp
@@ -17,19 +17,23 @@
#include "users.h"
#include "commands.h"
#include "helperfuncs.h"
+#include "inspircd.h"
#include "commands/cmd_lusers.h"
+extern InspIRCd* ServerInstance;
+
void cmd_lusers::Handle (const char** parameters, int pcnt, userrec *user)
{
// this lusers command shows one server at all times because
// a protocol module must override it to show those stats.
- user->WriteServ("251 %s :There are %d users and %d invisible on 1 server",user->nick,usercnt()-usercount_invisible(),usercount_invisible());
- if (usercount_opers())
- user->WriteServ("252 %s %d :operator(s) online",user->nick,usercount_opers());
- if (usercount_unknown())
- user->WriteServ("253 %s %d :unknown connections",user->nick,usercount_unknown());
- if (chancount())
- user->WriteServ("254 %s %d :channels formed",user->nick,chancount());
- if (local_count())
- user->WriteServ("254 %s :I have %d clients and 0 servers",user->nick,local_count());
+ user->WriteServ("251 %s :There are %d users and %d invisible on 1 server",user->nick,ServerInstance->usercnt()-ServerInstance->usercount_invisible(),ServerInstance->usercount_invisible());
+ if (ServerInstance->usercount_opers())
+ user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->usercount_opers());
+ if (ServerInstance->usercount_unknown())
+ user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->usercount_unknown());
+ if (ServerInstance->chancount())
+ user->WriteServ("254 %s %d :channels formed",user->nick,ServerInstance->chancount());
+ if (ServerInstance->local_count())
+ user->WriteServ("254 %s :I have %d clients and 0 servers",user->nick,ServerInstance->local_count());
}
+
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index fcadaddaf..f1e814198 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -30,7 +30,6 @@
#include "commands/cmd_notice.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
@@ -57,7 +56,7 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
const char* servermask = parameters[0] + 1;
if (match(ServerInstance->Config->ServerName,servermask))
{
- NoticeAll(user, true, "%s",parameters[1]);
+ user->NoticeAll("%s",parameters[1]);
}
FOREACH_MOD(I_OnUserMessage,OnUserNotice(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0));
return;
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index d11f630a2..8a2175ecc 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -27,7 +27,6 @@
#include "commands/cmd_privmsg.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
extern ModuleList modules;
extern FactoryList factory;
@@ -55,7 +54,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
const char* servermask = parameters[0] + 1;
if (match(ServerInstance->Config->ServerName,servermask))
{
- ServerPrivmsgAll("%s",parameters[1]);
+ ServerInstance->ServerPrivmsgAll("%s",parameters[1]);
}
FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0));
return;
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index f24abbe7c..feaab0fe4 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -40,7 +40,6 @@ extern int MODCOUNT;
extern ModuleList modules;
extern FactoryList factory;
extern time_t TIME;
-extern std::vector<userrec*> local_users;
void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
{
@@ -91,10 +90,10 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
if (user->fd > -1)
{
ServerInstance->SE->DelFd(user->fd);
- if (find(local_users.begin(),local_users.end(),user) != local_users.end())
+ if (find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user) != ServerInstance->local_users.end())
{
log(DEBUG,"Delete local user");
- local_users.erase(find(local_users.begin(),local_users.end(),user));
+ ServerInstance->local_users.erase(find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user));
}
user->CloseSocket();
}
diff --git a/src/cmd_restart.cpp b/src/cmd_restart.cpp
index baf5104f9..81c45386f 100644
--- a/src/cmd_restart.cpp
+++ b/src/cmd_restart.cpp
@@ -20,7 +20,7 @@
#include "helperfuncs.h"
#include "commands/cmd_restart.h"
-extern InspIRCd* ServerInstance;;
+extern InspIRCd* ServerInstance;
void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
{
@@ -43,7 +43,7 @@ void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
argv[3] = NULL;
// close ALL file descriptors
- send_error("Server restarting.");
+ ServerInstance->SendError("Server restarting.");
sleep(1);
for (int i = 0; i < MAX_DESCRIPTORS; i++)
{
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp
index 30cc2eb0d..6f124d6eb 100644
--- a/src/cmd_stats.cpp
+++ b/src/cmd_stats.cpp
@@ -48,7 +48,6 @@ extern int MODCOUNT;
extern ModuleList modules;
extern FactoryList factory;
extern time_t TIME;
-extern std::vector<userrec*> local_users;
void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user)
{
@@ -212,7 +211,7 @@ void DoStats(char statschar, userrec* user, string_list &results)
if (statschar == 'l')
{
results.push_back(sn+" 211 "+user->nick+" :nick[ident@host] sendq cmds_out bytes_out cmds_in bytes_in time_open");
- for (std::vector<userrec*>::iterator n = local_users.begin(); n != local_users.end(); n++)
+ for (std::vector<userrec*>::iterator n = ServerInstance->local_users.begin(); n != ServerInstance->local_users.end(); n++)
{
userrec* i = *n;
if (isnick(i->nick))
@@ -226,7 +225,7 @@ void DoStats(char statschar, userrec* user, string_list &results)
if (statschar == 'L')
{
results.push_back(sn+" 211 "+user->nick+" :nick[ident@ip] sendq cmds_out bytes_out cmds_in bytes_in time_open");
- for (std::vector<userrec*>::iterator n = local_users.begin(); n != local_users.end(); n++)
+ for (std::vector<userrec*>::iterator n = ServerInstance->local_users.begin(); n != ServerInstance->local_users.end(); n++)
{
userrec* i = *n;
if (isnick(i->nick))
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 57c8f44c1..4a375f365 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -53,7 +53,6 @@ extern InspIRCd* ServerInstance;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-extern std::vector<userrec*> local_users;
extern int MODCOUNT;
extern time_t TIME;
diff --git a/src/commands.cpp b/src/commands.cpp
index 8504c174d..b1eb51490 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -64,7 +64,6 @@ const long duration_w = duration_d * 7;
const long duration_y = duration_w * 52;
extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
void split_chlist(userrec* user, userrec* dest, const std::string &cl)
{
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index e9b969ee2..1f2a6646b 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -16,7 +16,6 @@
#include <stdarg.h>
#include "inspircd_config.h"
-#include "inspircd.h"
#include "configreader.h"
#include <unistd.h>
#include <fcntl.h>
@@ -43,6 +42,7 @@
#include "helperfuncs.h"
#include "hashcomp.h"
#include "typedefs.h"
+#include "inspircd.h"
extern int MODCOUNT;
extern ModuleList modules;
@@ -53,8 +53,6 @@ extern std::vector<userrec*> all_opers;
char LOG_FILE[MAXBUF];
-extern std::vector<userrec*> local_users;
-
static char TIMESTR[26];
static time_t LAST = 0;
@@ -169,7 +167,7 @@ void WriteOpers_NoFormat(const char* text)
}
}
-void ServerNoticeAll(char* text, ...)
+void InspIRCd::ServerNoticeAll(char* text, ...)
{
if (!text)
return;
@@ -190,7 +188,7 @@ void ServerNoticeAll(char* text, ...)
}
}
-void ServerPrivmsgAll(char* text, ...)
+void InspIRCd::ServerPrivmsgAll(char* text, ...)
{
if (!text)
return;
@@ -211,7 +209,7 @@ void ServerPrivmsgAll(char* text, ...)
}
}
-void WriteMode(const char* modes, int flags, const char* text, ...)
+void InspIRCd::WriteMode(const char* modes, int flags, const char* text, ...)
{
char textbuffer[MAXBUF];
int modelen;
@@ -267,32 +265,6 @@ void WriteMode(const char* modes, int flags, const char* text, ...)
}
}
-void NoticeAll(userrec *source, bool local_only, char* text, ...)
-{
- char textbuffer[MAXBUF];
- char formatbuffer[MAXBUF];
- va_list argsPtr;
-
- if ((!text) || (!source))
- {
- log(DEFAULT,"*** BUG *** NoticeAll was given an invalid parameter");
- return;
- }
-
- va_start(argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- snprintf(formatbuffer,MAXBUF,"NOTICE $* :%s",textbuffer);
-
- for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
- {
- userrec* t = *i;
- t->WriteFrom(source,std::string(formatbuffer));
- }
-}
-
-
/* convert a string to lowercase. Note following special circumstances
* taken from RFC 1459. Many "official" server branches still hold to this
* rule so i will too;
@@ -557,12 +529,6 @@ int usercount_i(chanrec *c)
return count;
}
-int usercount(chanrec *c)
-{
- return (c ? c->GetUserCounter() : 0);
-}
-
-
/* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
* NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
* then their ip will be taken as 'priority' anyway, so for example,
@@ -585,11 +551,9 @@ ConnectClass GetClass(userrec *user)
* sends out an error notice to all connected clients (not to be used
* lightly!)
*/
-void send_error(char *s)
+void InspIRCd::SendError(const char *s)
{
- log(DEBUG,"send_error: %s",s);
-
- for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+ for (std::vector<userrec*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
{
userrec* t = (userrec*)(*i);
if (t->registered == REG_ALL)
@@ -630,7 +594,7 @@ void Error(int status)
#else
log(DEFAULT,"You do not have execinfo.h so i could not backtrace -- on FreeBSD, please install the libexecinfo port.");
#endif
- send_error("Somebody screwed up... Whoops. IRC Server terminating.");
+ ServerInstance->SendError("Somebody screwed up... Whoops. IRC Server terminating.");
signal(SIGSEGV, SIG_DFL);
if (raise(SIGSEGV) == -1)
{
@@ -640,17 +604,17 @@ void Error(int status)
}
// this function counts all users connected, wether they are registered or NOT.
-int usercnt(void)
+int InspIRCd::usercnt()
{
- return ServerInstance->clientlist.size();
+ return clientlist.size();
}
// this counts only registered users, so that the percentages in /MAP don't mess up when users are sitting in an unregistered state
-int registered_usercount(void)
+int InspIRCd::registered_usercount()
{
int c = 0;
- for (user_hash::const_iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++)
+ for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
{
c += (i->second->registered == REG_ALL);
}
@@ -658,11 +622,11 @@ int registered_usercount(void)
return c;
}
-int usercount_invisible(void)
+int InspIRCd::usercount_invisible()
{
int c = 0;
- for (user_hash::const_iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++)
+ for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
{
c += ((i->second->registered == REG_ALL) && (i->second->modes[UM_INVISIBLE]));
}
@@ -670,11 +634,11 @@ int usercount_invisible(void)
return c;
}
-int usercount_opers(void)
+int InspIRCd::usercount_opers()
{
int c = 0;
- for (user_hash::const_iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++)
+ for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
{
if (*(i->second->oper))
c++;
@@ -682,7 +646,7 @@ int usercount_opers(void)
return c;
}
-int usercount_unknown(void)
+int InspIRCd::usercount_unknown()
{
int c = 0;
@@ -696,12 +660,12 @@ int usercount_unknown(void)
return c;
}
-long chancount(void)
+long InspIRCd::chancount()
{
- return ServerInstance->chanlist.size();
+ return chanlist.size();
}
-long local_count()
+long InspIRCd::local_count()
{
int c = 0;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 5c3afe70c..ecda5abb9 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -70,8 +70,6 @@ InspIRCd* ServerInstance;
extern ModuleList modules;
extern FactoryList factory;
-std::vector<userrec*> local_users;
-
extern int MODCOUNT;
extern char LOG_FILE[MAXBUF];
@@ -115,7 +113,7 @@ void Exit(int status)
{
if (ServerInstance->Config->log_file)
fclose(ServerInstance->Config->log_file);
- send_error("Server shutdown.");
+ ServerInstance->SendError("Server shutdown.");
exit (status);
}
@@ -132,7 +130,7 @@ void Killed(int status)
{
if (ServerInstance->Config->log_file)
fclose(ServerInstance->Config->log_file);
- send_error("Server terminated.");
+ ServerInstance->SendError("Server terminated.");
exit(status);
}
@@ -961,7 +959,7 @@ int main(int argc, char** argv)
catch (std::bad_alloc)
{
log(DEFAULT,"You are out of memory! (got exception std::bad_alloc!)");
- send_error("**** OUT OF MEMORY **** We're gonna need a bigger boat!");
+ ServerInstance->SendError("**** OUT OF MEMORY **** We're gonna need a bigger boat!");
printf("Out of memory! (got exception std::bad_alloc!");
}
return 0;
diff --git a/src/modules.cpp b/src/modules.cpp
index 1c90bd7c0..46b6a16d1 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -15,7 +15,7 @@
*/
#include "inspircd_config.h"
-#include "inspircd.h"
+//#include "inspircd.h"
#include "configreader.h"
#include <unistd.h>
#include <sys/errno.h>
@@ -44,12 +44,12 @@
#include "modules.h"
#include "command_parse.h"
#include "dns.h"
+#include "inspircd.h"
extern InspIRCd* ServerInstance;
extern int MODCOUNT;
extern ModuleList modules;
extern FactoryList factory;
-extern std::vector<userrec*> local_users;
extern time_t TIME;
extern command_table cmdlist;
@@ -390,11 +390,6 @@ bool Server::MatchText(const std::string &sliteral, const std::string &spattern)
return match(sliteral.c_str(),spattern.c_str());
}
-void Server::SendToModeMask(const std::string &modes, int flags, const std::string &text)
-{
- WriteMode(modes.c_str(),flags,"%s",text.c_str());
-}
-
bool Server::IsUlined(const std::string &server)
{
return is_uline(server.c_str());
@@ -511,12 +506,7 @@ bool Server::AddResolver(Resolver* r)
return ServerInstance->Res->AddResolverClass(r);
}
-int Server::CountUsers(chanrec* c)
-{
- return usercount(c);
-}
-
-bool Server::UserToPseudo(userrec* user, const std::string &message)
+bool InspIRCd::UserToPseudo(userrec* user, const std::string &message)
{
unsigned int old_fd = user->fd;
user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,message.c_str());
@@ -536,7 +526,7 @@ bool Server::UserToPseudo(userrec* user, const std::string &message)
return true;
}
-bool Server::PseudoToUser(userrec* alive, userrec* zombie, const std::string &message)
+bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &message)
{
log(DEBUG,"PseudoToUser");
zombie->fd = alive->fd;
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index 3764b400e..53e725504 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -308,7 +308,7 @@ class ModuleChanProtect : public Module
// the config option for it is set
if (FirstInGetsFounder)
{
- if (Srv->CountUsers(channel) == 1)
+ if (channel->GetUserCounter() == 1)
{
// we're using Extensible::Extend to add data into user objects.
// this way is best as it adds data thats accessible to other modules
diff --git a/src/modules/m_globops.cpp b/src/modules/m_globops.cpp
index 2b2af1539..a02ad1172 100644
--- a/src/modules/m_globops.cpp
+++ b/src/modules/m_globops.cpp
@@ -28,6 +28,7 @@ using namespace std;
/* $ModDesc: Provides support for GLOBOPS and user mode +g */
static Server *Srv;
+extern InspIRCd* ServerInstance;
class cmd_globops : public command_t
{
@@ -45,7 +46,7 @@ class cmd_globops : public command_t
{
line = line + std::string(parameters[i]) + " ";
}
- Srv->SendToModeMask("og",WM_AND,line);
+ ServerInstance->WriteMode("og",WM_AND,line.c_str());
}
};
diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp
index 69f61ab1a..28e826276 100644
--- a/src/modules/m_helpop.cpp
+++ b/src/modules/m_helpop.cpp
@@ -26,6 +26,8 @@ using namespace std;
static ConfigReader *helpop;
static Server *Srv;
+extern InspIRCd* ServerInstance;
+
bool do_helpop(const char**, int, userrec*);
void sendtohelpop(userrec*, int, const char**);
@@ -177,7 +179,7 @@ void sendtohelpop(userrec *src, int pcnt, const char **params)
{
line = line + std::string(params[i]) + " ";
}
- Srv->SendToModeMask("oh",WM_AND,line);
+ ServerInstance->WriteMode("oh",WM_AND,line.c_str());
}
class HelpopException : public ModuleException
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 9cb2e28ae..c16a2125f 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -225,7 +225,7 @@ class ModuleOverride : public Module
return -1;
}
- if ((chan->limit > 0) && (Srv->CountUsers(chan) >= chan->limit) && (CanOverride(user,"LIMIT")))
+ if ((chan->limit > 0) && (chan->GetUserCounter() >= chan->limit) && (CanOverride(user,"LIMIT")))
{
if (NoisyOverride)
chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s passed through your channel limit", cname, user->nick);
diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp
index e26af09f2..779a4e8a0 100644
--- a/src/modules/m_park.cpp
+++ b/src/modules/m_park.cpp
@@ -25,6 +25,8 @@ using namespace std;
#include "modules.h"
#include "inspircd.h"
+extern InspIRCd* ServerInstance;
+
/* $ModDesc: Provides support for user parking/unparking */
class parking : public classbase
@@ -88,7 +90,7 @@ class cmd_park : public command_t
unsigned long* key = new unsigned long;
*key = abs(random() * 12345);
snprintf(msg,MAXBUF,"You are now parked. To unpark use /UNPARK %s %lu",user->nick, *key);
- Srv->UserToPseudo(user,std::string(msg));
+ ServerInstance->UserToPseudo(user,std::string(msg));
aw = new awaylog;
user->Extend("park_awaylog", aw);
user->Extend("park_key", key);
@@ -174,7 +176,7 @@ class cmd_unpark : public command_t
// remove all their old modes
user->WriteServ("MODE %s -%s",user->nick,user->FormatModes());
// now, map them to the parked user, while nobody can see :p
- Srv->PseudoToUser(user,unpark,"Unparked to "+std::string(parameters[0]));
+ ServerInstance->PseudoToUser(user,unpark,"Unparked to "+std::string(parameters[0]));
// set all their new modes
unpark->WriteServ("MODE %s +%s",unpark->nick,unpark->FormatModes());
// spool their away log to them
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index ae45c67a3..d7f82f38e 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -135,7 +135,7 @@ class ModuleRedirect : public Module
{
if (chan->IsModeSet('L'))
{
- if (Srv->CountUsers(chan) >= chan->limit)
+ if (chan->GetUserCounter() >= chan->limit)
{
std::string channel = chan->GetModeParameter('L');
user->WriteServ("470 %s :%s has become full, so you are automatically being transferred to the linked channel %s",user->nick,cname,channel.c_str());
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index 38985dcb5..45177805e 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -102,7 +102,7 @@ class ListTimer : public InspTimer
bool has_user = (chan && chan->HasUser(u));
if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user)))
{
- long users = usercount(chan);
+ long users = chan->GetUserCounter();
if (users)
{
int counter = snprintf(buffer,MAXBUF,"322 %s %s %ld :[+%s] %s",u->nick,chan->name,users,chanmodes(chan,has_user),chan->topic);
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index d0d7389de..3206c5621 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -3483,23 +3483,23 @@ class ModuleSpanningTree : public Module
void HandleLusers(const char** parameters, int pcnt, userrec* user)
{
- unsigned int n_users = usercnt();
+ unsigned int n_users = ServerInstance->usercnt();
/* Only update these when someone wants to see them, more efficient */
- if ((unsigned int)local_count() > max_local)
- max_local = local_count();
+ if ((unsigned int)ServerInstance->local_count() > max_local)
+ max_local = ServerInstance->local_count();
if (n_users > max_global)
max_global = n_users;
- user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick,n_users-usercount_invisible(),usercount_invisible(),this->CountServs());
- if (usercount_opers())
- user->WriteServ("252 %s %d :operator(s) online",user->nick,usercount_opers());
- if (usercount_unknown())
- user->WriteServ("253 %s %d :unknown connections",user->nick,usercount_unknown());
- if (chancount())
- user->WriteServ("254 %s %d :channels formed",user->nick,chancount());
- user->WriteServ("254 %s :I have %d clients and %d servers",user->nick,local_count(),this->CountLocalServs());
- user->WriteServ("265 %s :Current Local Users: %d Max: %d",user->nick,local_count(),max_local);
+ user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick,n_users-ServerInstance->usercount_invisible(),ServerInstance->usercount_invisible(),this->CountServs());
+ if (ServerInstance->usercount_opers())
+ user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->usercount_opers());
+ if (ServerInstance->usercount_unknown())
+ user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->usercount_unknown());
+ if (ServerInstance->chancount())
+ user->WriteServ("254 %s %d :channels formed",user->nick,ServerInstance->chancount());
+ user->WriteServ("254 %s :I have %d clients and %d servers",user->nick,ServerInstance->local_count(),this->CountLocalServs());
+ user->WriteServ("265 %s :Current Local Users: %d Max: %d",user->nick,ServerInstance->local_count(),max_local);
user->WriteServ("266 %s :Current Global Users: %d Max: %d",user->nick,n_users,max_global);
return;
}
diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp
index faf4e431a..40be036ab 100644
--- a/src/modules/m_spy.cpp
+++ b/src/modules/m_spy.cpp
@@ -98,7 +98,7 @@ class cmd_spylist : public command_t
user->WriteServ("321 %s Channel :Users Name",user->nick);
for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
{
- user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount(i->second),chanmodes(i->second,true),i->second->topic);
+ user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,i->second->GetUserCounter(),chanmodes(i->second,true),i->second->topic);
}
user->WriteServ("323 %s :End of channel list.",user->nick);
}
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 88fdeec54..8b9235436 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -58,7 +58,6 @@ extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern time_t TIME;
extern time_t OLDTIME;
-extern std::vector<userrec*> local_users;
char data[65536];
void InspIRCd::ProcessUser(userrec* cu)
@@ -307,12 +306,12 @@ void InspIRCd::DoBackgroundUserStuff(time_t TIME)
CullList GlobalGoners;
/* XXX: IT IS NOT SAFE TO USE AN ITERATOR HERE. DON'T EVEN THINK ABOUT IT. */
- for (unsigned long count2 = 0; count2 != local_users.size(); count2++)
+ for (unsigned long count2 = 0; count2 != this->local_users.size(); count2++)
{
- if (count2 >= local_users.size())
+ if (count2 >= this->local_users.size())
break;
- userrec* curr = local_users[count2];
+ userrec* curr = this->local_users[count2];
if (curr)
{
diff --git a/src/users.cpp b/src/users.cpp
index cb6fbc1f3..40c29ded1 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -39,7 +39,6 @@ extern std::vector<InspSocket*> module_sockets;
extern int MODCOUNT;
extern time_t TIME;
extern Server* MyServer;
-extern std::vector<userrec*> local_users;
irc::whowas::whowas_users whowas;
static unsigned long already_sent[MAX_DESCRIPTORS] = {0};
@@ -713,8 +712,8 @@ void userrec::QuitUser(userrec *user,const std::string &quitreason)
if (IS_LOCAL(user))
{
ServerInstance->fd_ref_table[user->fd] = NULL;
- if (find(local_users.begin(),local_users.end(),user) != local_users.end())
- local_users.erase(find(local_users.begin(),local_users.end(),user));
+ if (find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user) != ServerInstance->local_users.end())
+ ServerInstance->local_users.erase(find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user));
}
ServerInstance->clientlist.erase(iter);
DELETE(user);
@@ -873,15 +872,15 @@ void userrec::AddClient(int socket, int port, bool iscached, insp_inaddr ip)
_new->recvqmax = class_rqmax;
ServerInstance->fd_ref_table[socket] = _new;
- local_users.push_back(_new);
+ ServerInstance->local_users.push_back(_new);
- if (local_users.size() > ServerInstance->Config->SoftLimit)
+ if (ServerInstance->local_users.size() > ServerInstance->Config->SoftLimit)
{
userrec::QuitUser(_new,"No more connections allowed");
return;
}
- if (local_users.size() >= MAXCLIENTS)
+ if (ServerInstance->local_users.size() >= MAXCLIENTS)
{
userrec::QuitUser(_new,"No more connections allowed");
return;
@@ -946,7 +945,7 @@ long userrec::GlobalCloneCount()
long userrec::LocalCloneCount()
{
long x = 0;
- for (std::vector<userrec*>::const_iterator a = local_users.begin(); a != local_users.end(); a++)
+ for (std::vector<userrec*>::const_iterator a = ServerInstance->local_users.begin(); a != ServerInstance->local_users.end(); a++)
{
userrec* comp = *a;
#ifdef IPV6
@@ -1538,7 +1537,7 @@ void userrec::WriteWallOps(const std::string &text)
std::string wallop = "WALLOPS :";
wallop.append(text);
- for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+ for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
{
userrec* t = *i;
if ((IS_LOCAL(t)) && (t->modes[UM_WALLOPS]))
@@ -1634,3 +1633,22 @@ bool userrec::ChangeDisplayedHost(const char* host)
return true;
}
+void userrec::NoticeAll(char* text, ...)
+{
+ char textbuffer[MAXBUF];
+ char formatbuffer[MAXBUF];
+ va_list argsPtr;
+
+ va_start(argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+
+ snprintf(formatbuffer,MAXBUF,"NOTICE $* :%s",textbuffer);
+
+ for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
+ {
+ userrec* t = *i;
+ t->WriteFrom(this, std::string(formatbuffer));
+ }
+}
+
diff --git a/src/xline.cpp b/src/xline.cpp
index 868508db6..d3821b528 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -44,7 +44,6 @@ extern InspIRCd* ServerInstance;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-extern std::vector<userrec*> local_users;
/* Version two, now with optimized expiry!
*
@@ -665,7 +664,7 @@ void apply_lines(const int What)
CullList* Goners = new CullList();
char* check = NULL;
- for (std::vector<userrec*>::const_iterator u2 = local_users.begin(); u2 != local_users.end(); u2++)
+ for (std::vector<userrec*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
{
userrec* u = (userrec*)(*u2);
u->MakeHost(host);