]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move some stuff to usermanager, remove a little header insanity, remove trace because...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 2 Feb 2008 20:55:16 +0000 (20:55 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 2 Feb 2008 20:55:16 +0000 (20:55 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8790 e03df62e-2008-0410-955e-edbf42e46eb7

33 files changed:
include/command_parse.h
include/inspircd.h
include/typedefs.h
include/usermanager.h
src/commands.cpp
src/commands/cmd_lusers.cpp
src/commands/cmd_stats.cpp
src/commands/cmd_trace.cpp [deleted file]
src/commands/cmd_who.cpp
src/configreader.cpp
src/cull_list.cpp
src/helperfuncs.cpp
src/inspircd.cpp
src/mode.cpp
src/modes/umode_o.cpp
src/modules.cpp
src/modules/m_callerid.cpp
src/modules/m_check.cpp
src/modules/m_close.cpp
src/modules/m_httpd_stats.cpp
src/modules/m_invisible.cpp
src/modules/m_jumpserver.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/override_map.cpp
src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/treesocket1.cpp
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_tline.cpp
src/snomasks.cpp
src/usermanager.cpp
src/userprocess.cpp
src/users.cpp
src/xline.cpp

index 93a36885ccd4a8fd241fd733cf1a5b0251d719b7..c2fa781772237f5cc5a185dc447e98173dcaf631 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <string>
 #include "ctables.h"
-#include "typedefs.h"
 
 /** Required forward declaration
  */
index fb6b313a2d4c4b866d22db57f95ac42dd7e585e4..d78e25b48d287f9c9d6ba7b8e3bbda42f7293dea 100644 (file)
 #undef ERROR
 #endif
 
+// Required system headers.
 #include <time.h>
-#include <string>
-#include <sstream>
-#include <list>
+#include <stdarg.h>
+
+
+//#include <string>
+//#include <sstream>
 #include "inspircd_config.h"
 #include "uid.h"
 #include "users.h"
-#include "usermanager.h"
 #include "channels.h"
+#include "hashcomp.h"
+#include "typedefs.h"
+#include "usermanager.h"
 #include "socket.h"
 #include "mode.h"
 #include "socketengine.h"
@@ -358,11 +363,6 @@ class CoreExport InspIRCd : public classbase
         */
        void BuildISupport();
 
-       /** Number of unregistered users online right now.
-        * (Unregistered means before USER/NICK/dns)
-        */
-       int unregistered_count;
-
        /** List of server names we've seen.
         */
        servernamelist servernames;
@@ -410,27 +410,6 @@ class CoreExport InspIRCd : public classbase
         */
        SnomaskManager* SNO;
 
-       /** Client list, a hash_map containing all clients, local and remote
-        */
-       user_hash* clientlist;
-
-       /** Client list stored by UUID. Contains all clients, and is updated
-        * automatically by the constructor and destructor of User.
-        */
-       user_hash* uuidlist;
-
-       /** Channel list, a hash_map containing all channels
-        */
-       chan_hash* chanlist;
-
-       /** Local client list, a vector containing only local clients
-        */
-       std::vector<User*> local_users;
-
-       /** Oper list, a vector containing all local and remote opered users
-        */
-       std::list<User*> all_opers;
-
        /** DNS class, provides resolver facilities to the core and modules
         */
        DNS* Res;
@@ -447,6 +426,10 @@ class CoreExport InspIRCd : public classbase
         */
        UserManager *Users;
 
+       /** Channel list, a hash_map containing all channels XXX move to channel manager class
+        */
+       chan_hash* chanlist;
+
        /** Set to the current signal recieved
         */
        int s_signal;
@@ -466,10 +449,6 @@ class CoreExport InspIRCd : public classbase
         * @return The old time delta
         */
        int SetTimeDelta(int delta);
-       
-       /** Number of users with a certain mode set on them
-        */
-       int ModeCount(const char mode);
 
        /** Get the time offset in seconds
         * @return The current time delta (in seconds)
@@ -580,28 +559,6 @@ class CoreExport InspIRCd : public classbase
         */
        void CloseLog();
 
-       /** Send a server notice to all local users
-        * @param text The text format string to send
-        * @param ... The format arguments
-        */
-       void ServerNoticeAll(char* text, ...);
-
-       /** Send a server message (PRIVMSG) to all local users
-        * @param text The text format string to send
-        * @param ... The format arguments
-        */
-       void ServerPrivmsgAll(char* text, ...);
-
-       /** Send text to all users with a specific set of modes
-        * @param modes The modes to check against, without a +, e.g. 'og'
-        * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the
-        * mode characters in the first parameter causes receipt of the message, and
-        * if you specify WM_OR, all the modes must be present.
-        * @param text The text format string to send
-        * @param ... The format arguments
-        */
-       void WriteMode(const char* modes, int flags, const char* text, ...);
-
        /** Return true if a channel name is valid
         * @param chname A channel name to verify
         * @return True if the name is valid
index 44d24b1f6344fef0e3b36c6144035015eb8c9c3e..2a98da4aec4ccb6de27003cc8b57a903aa195dd6 100644 (file)
 #ifndef __TYPEDEF_H__
 #define __TYPEDEF_H__
 
-
-#include <string>
-#include "inspircd_config.h"
-#include "hash_map.h"
-#include "users.h"
-#include "channels.h"
-#include "hashcomp.h"
-#include "inspstring.h"
-#include "ctables.h"
-#include "modules.h"
-#include "globals.h"
-
 #ifndef WIN32
 /** User hash (POSIX systems with GCC)
  */
index f994e9739a59026cf67f54d6c16cd2404637be59..33b97129a9bf1ad143d2757e596bbe39b7fd3026 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef __USERMANAGER_H
 #define __USERMANAGER_H
 
+#include <list>
+
 /** A list of ip addresses cross referenced against clone counts */
 typedef std::map<irc::string, unsigned int> clonemap;
 
@@ -31,6 +33,29 @@ class CoreExport UserManager : public classbase
                ServerInstance = Instance;
        }
 
+
+       /** Client list, a hash_map containing all clients, local and remote
+        */
+       user_hash* clientlist;
+
+       /** Client list stored by UUID. Contains all clients, and is updated
+        * automatically by the constructor and destructor of User.
+        */
+       user_hash* uuidlist;
+
+       /** Local client list, a vector containing only local clients
+        */
+       std::vector<User*> local_users;
+
+       /** Oper list, a vector containing all local and remote opered users
+        */
+       std::list<User*> all_opers;
+
+       /** Number of unregistered users online right now.
+        * (Unregistered means before USER/NICK/dns)
+        */
+       int unregistered_count;
+
        /** Map of global ip addresses for clone counting
         * XXX - this should be private, but m_clones depends on it currently.
         */
@@ -101,6 +126,35 @@ class CoreExport UserManager : public classbase
         * @return The number of local users
         */
        unsigned int LocalUserCount();
+
+
+
+
+       /** Number of users with a certain mode set on them
+        */
+       int ModeCount(const char mode);
+
+       /** Send a server notice to all local users
+        * @param text The text format string to send
+        * @param ... The format arguments
+        */
+       void ServerNoticeAll(char* text, ...);
+
+       /** Send a server message (PRIVMSG) to all local users
+        * @param text The text format string to send
+        * @param ... The format arguments
+        */
+       void ServerPrivmsgAll(char* text, ...);
+
+       /** Send text to all users with a specific set of modes
+        * @param modes The modes to check against, without a +, e.g. 'og'
+        * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the
+        * mode characters in the first parameter causes receipt of the message, and
+        * if you specify WM_OR, all the modes must be present.
+        * @param text The text format string to send
+        * @param ... The format arguments
+        */
+       void WriteMode(const char* modes, int flags, const char* text, ...);
 };
 
 #endif
index 495fb821b32d52fbe188b98ccba8a270f8a5ecb3..0172646210db611a66ac93861db1be1df1286348 100644 (file)
@@ -31,7 +31,7 @@ bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user)
        if (Config->ConfValueBool(Config->config_data, "insane","hostmasks", 0))
                return false;
        
-       for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++)
+       for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
        {
                if ((match(u->second->MakeHost(),mask.c_str(),true)) || (match(u->second->MakeHostIP(),mask.c_str(),true)))
                {
@@ -42,7 +42,7 @@ bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user)
        if (!matches)
                return false;
 
-       float percent = ((float)matches / (float)clientlist->size()) * 100;
+       float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
        if (percent > (float)atof(itrigger))
        {
                SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent);
@@ -62,7 +62,7 @@ bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user)
        if (Config->ConfValueBool(Config->config_data, "insane","ipmasks",0))
                return false;
        
-       for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++)
+       for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
        {
                if (match(u->second->GetIPString(),ip.c_str(),true))
                        matches++;
@@ -71,7 +71,7 @@ bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user)
        if (!matches)
                return false;
 
-       float percent = ((float)matches / (float)clientlist->size()) * 100;
+       float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
        if (percent > (float)atof(itrigger))
        {
                SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent);
@@ -91,7 +91,7 @@ bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user)
        if (Config->ConfValueBool(Config->config_data, "insane","nickmasks",0))
                return false;
 
-       for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++)
+       for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
        {
                if (match(u->second->nick,nick.c_str()))
                        matches++;
@@ -100,7 +100,7 @@ bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user)
        if (!matches)
                return false;
 
-       float percent = ((float)matches / (float)clientlist->size()) * 100;
+       float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
        if (percent > (float)atof(itrigger))
        {
                SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent);
index f91266a158b667d0654b7f0c7e33255e97c241d2..317229ceb4f1c1c640a557ba77cc9878ba12b250 100644 (file)
@@ -25,7 +25,7 @@ CmdResult CommandLusers::Handle (const char**, int, User *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,ServerInstance->Users->UserCount()-ServerInstance->ModeCount('i'),ServerInstance->ModeCount('i'));
+       user->WriteServ("251 %s :There are %d users and %d invisible on 1 server",user->nick,ServerInstance->Users->UserCount()-ServerInstance->Users->ModeCount('i'),ServerInstance->Users->ModeCount('i'));
        if (ServerInstance->Users->OperCount())
                user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->Users->OperCount());
        if (ServerInstance->Users->UnregisteredUserCount())
index 3d81dd84f1715325db9aae75f864658f225f11da..de9237c612e30a685a8f8c6e4a7cb3b56e8977e3 100644 (file)
@@ -126,7 +126,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str
                case 'P':
                {
                        int idx = 0;
-                       for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++)
+                       for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++)
                        {
                                if (IS_OPER(i->second) && !ServerInstance->ULine(i->second->server))
                                {
@@ -171,7 +171,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str
                case 'z':
                {
                        results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes");
-                       results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(User))+" bytes)");
+                       results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->Users->clientlist->size())+" ("+ConvToStr(ServerInstance->Users->clientlist->size()*sizeof(User))+" bytes)");
                        results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(Channel))+" bytes)");
                        results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(Command))+" bytes)");
 
@@ -255,7 +255,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str
                /* stats l (show user I/O stats) */
                case '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<User*>::iterator n = ServerInstance->local_users.begin(); n != ServerInstance->local_users.end(); n++)
+                       for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++)
                        {
                                User* i = *n;
                                if (ServerInstance->IsNick(i->nick))
@@ -268,7 +268,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str
        /* stats L (show user I/O stats with IP addresses) */
                case '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<User*>::iterator n = ServerInstance->local_users.begin(); n != ServerInstance->local_users.end(); n++)
+                       for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++)
                        {
                                User* i = *n;
                                if (ServerInstance->IsNick(i->nick))
diff --git a/src/commands/cmd_trace.cpp b/src/commands/cmd_trace.cpp
deleted file mode 100644 (file)
index b81a732..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
- *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "commands/cmd_trace.h"
-
-extern "C" DllExport Command* init_command(InspIRCd* Instance)
-{
-       return new CommandTrace(Instance);
-}
-
-/** XXX: This is crap. someone fix this when you have time, to be more useful.
- */
-CmdResult CommandTrace::Handle (const char**, int, User *user)
-{
-       for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++)
-       {
-               if (i->second->registered == REG_ALL)
-               {
-                       if (IS_OPER(i->second))
-                       {
-                               user->WriteServ("205 %s :Oper 0 %s",user->nick,i->second->nick);
-                       }
-                       else
-                       {
-                               user->WriteServ("204 %s :User 0 %s",user->nick,i->second->nick);
-                       }
-               }
-               else
-               {
-                       user->WriteServ("203 %s :???? 0 [%s]",user->nick,i->second->host);
-               }
-       }
-       return CMD_SUCCESS;
-}
index 1a323edd4f1a414faa78d3bd3dfdbb867f182579..091ba728b45c6baca97ce2780db1f3b74e00c959 100644 (file)
@@ -298,7 +298,7 @@ CmdResult CommandWho::Handle (const char** parameters, int pcnt, User *user)
                if (opt_viewopersonly)
                {
                        /* Showing only opers */
-                       for (std::list<User*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
+                       for (std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); i++)
                        {
                                User* oper = *i;
 
@@ -316,7 +316,7 @@ CmdResult CommandWho::Handle (const char** parameters, int pcnt, User *user)
                }
                else
                {
-                       for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++)
+                       for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++)
                        {
                                if (whomatch(i->second, matchtext))
                                {
index a9c41be7be83d564c0496bc0f9c616e33c6b3863..945780a54f4600aeee3d11a7c81ee367383cec08 100644 (file)
@@ -2298,7 +2298,7 @@ bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &val
 // this should probably be moved to configreader, but atm it relies on CheckELines above.
 bool DoneELine(ServerConfig* conf, const char* tag)
 {
-       for (std::vector<User*>::const_iterator u2 = conf->GetInstance()->local_users.begin(); u2 != conf->GetInstance()->local_users.end(); u2++)
+       for (std::vector<User*>::const_iterator u2 = conf->GetInstance()->Users->local_users.begin(); u2 != conf->GetInstance()->Users->local_users.end(); u2++)
        {
                User* u = (User*)(*u2);
                u->exempt = false;
index fee326ea3ccc324e33d040ceb61b5ec247bd90a4..b3fd1c9e382f7eae279db9c2870c081a2eac72dd 100644 (file)
@@ -49,7 +49,7 @@ int CullList::Apply()
                std::vector<User *>::iterator a = list.begin();
 
                User *u = (*a);
-               user_hash::iterator iter = ServerInstance->clientlist->find(u->nick);
+               user_hash::iterator iter = ServerInstance->Users->clientlist->find(u->nick);
                const char* preset_reason = u->GetOperQuit();
                std::string reason = u->operquitmsg;
                std::string oper_reason = *preset_reason ? preset_reason : u->operquitmsg;
@@ -60,8 +60,8 @@ int CullList::Apply()
                        oper_reason.resize(MAXQUIT - 1);
 
                if (u->registered != REG_ALL)
-                       if (ServerInstance->unregistered_count)
-                               ServerInstance->unregistered_count--;
+                       if (ServerInstance->Users->unregistered_count)
+                               ServerInstance->Users->unregistered_count--;
 
                if (IS_LOCAL(u))
                {
@@ -119,15 +119,15 @@ int CullList::Apply()
                        u->AddToWhoWas();
                }
 
-               if (iter != ServerInstance->clientlist->end())
+               if (iter != ServerInstance->Users->clientlist->end())
                {
                        if (IS_LOCAL(u))
                        {
-                               std::vector<User*>::iterator x = find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),u);
-                               if (x != ServerInstance->local_users.end())
-                                       ServerInstance->local_users.erase(x);
+                               std::vector<User*>::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),u);
+                               if (x != ServerInstance->Users->local_users.end())
+                                       ServerInstance->Users->local_users.erase(x);
                        }
-                       ServerInstance->clientlist->erase(iter);
+                       ServerInstance->Users->clientlist->erase(iter);
                }
 
                delete u;
index 2d8a6f060503502157280220ec86c28fe0707260..3f60cac80419acc443aab3e34f4bef9fe4bc03e8 100644 (file)
@@ -14,7 +14,6 @@
 /* $Core: libIRCDhelper */
 
 #include "inspircd.h"
-#include <stdarg.h>
 #include "wildcard.h"
 #include "xline.h"
 #include "exitcodes.h"
@@ -95,119 +94,15 @@ std::string InspIRCd::GetServerDescription(const char* servername)
        }
 }
 
-void InspIRCd::ServerNoticeAll(char* text, ...)
-{
-       if (!text)
-               return;
-
-       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 :%s",Config->ServerName,textbuffer);
-
-       for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
-       {
-               User* t = *i;
-               t->WriteServ(std::string(formatbuffer));
-       }
-}
-
-void InspIRCd::ServerPrivmsgAll(char* text, ...)
-{
-       if (!text)
-               return;
-
-       char textbuffer[MAXBUF];
-       char formatbuffer[MAXBUF];
-       va_list argsPtr;
-       va_start (argsPtr, text);
-       vsnprintf(textbuffer, MAXBUF, text, argsPtr);
-       va_end(argsPtr);
-
-       snprintf(formatbuffer,MAXBUF,"PRIVMSG $%s :%s",Config->ServerName,textbuffer);
-
-       for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
-       {
-               User* t = *i;
-               t->WriteServ(std::string(formatbuffer));
-       }
-}
-
-void InspIRCd::WriteMode(const char* modes, int flags, const char* text, ...)
-{
-       char textbuffer[MAXBUF];
-       int modelen;
-       va_list argsPtr;
-
-       if (!text || !modes || !flags)
-       {
-               this->Log(DEFAULT,"*** BUG *** WriteMode was given an invalid parameter");
-               return;
-       }
-
-       va_start(argsPtr, text);
-       vsnprintf(textbuffer, MAXBUF, text, argsPtr);
-       va_end(argsPtr);
-       modelen = strlen(modes);
-
-       if (flags == WM_AND)
-       {
-               for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
-               {
-                       User* t = *i;
-                       bool send_to_user = true;
-
-                       for (int n = 0; n < modelen; n++)
-                       {
-                               if (!t->IsModeSet(modes[n]))
-                               {
-                                       send_to_user = false;
-                                       break;
-                               }
-                       }
-                       if (send_to_user)
-                       {
-                               t->WriteServ("NOTICE %s :%s", t->nick, textbuffer);
-                       }
-               }
-       }
-       else if (flags == WM_OR)
-       {
-               for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
-               {
-                       User* t = *i;
-                       bool send_to_user = false;
-
-                       for (int n = 0; n < modelen; n++)
-                       {
-                               if (t->IsModeSet(modes[n]))
-                               {
-                                       send_to_user = true;
-                                       break;
-                               }
-                       }
-
-                       if (send_to_user)
-                       {
-                               t->WriteServ("NOTICE %s :%s", t->nick, textbuffer);
-                       }
-               }
-       }
-}
-
 /* Find a user record by nickname and return a pointer to it */
 User* InspIRCd::FindNick(const std::string &nick)
 {
        if (!nick.empty() && isdigit(*nick.begin()))
                return FindUUID(nick);
 
-       user_hash::iterator iter = clientlist->find(nick);
+       user_hash::iterator iter = this->Users->clientlist->find(nick);
 
-       if (iter == clientlist->end())
+       if (iter == this->Users->clientlist->end())
                /* Couldn't find it */
                return NULL;
 
@@ -219,9 +114,9 @@ User* InspIRCd::FindNick(const char* nick)
        if (isdigit(*nick))
                return FindUUID(nick);
 
-       user_hash::iterator iter = clientlist->find(nick);
+       user_hash::iterator iter = this->Users->clientlist->find(nick);
        
-       if (iter == clientlist->end())
+       if (iter == this->Users->clientlist->end())
                return NULL;
 
        return iter->second;
@@ -229,9 +124,9 @@ User* InspIRCd::FindNick(const char* nick)
 
 User* InspIRCd::FindNickOnly(const std::string &nick)
 {
-       user_hash::iterator iter = clientlist->find(nick);
+       user_hash::iterator iter = this->Users->clientlist->find(nick);
 
-       if (iter == clientlist->end())
+       if (iter == this->Users->clientlist->end())
                return NULL;
 
        return iter->second;
@@ -239,9 +134,9 @@ User* InspIRCd::FindNickOnly(const std::string &nick)
 
 User* InspIRCd::FindNickOnly(const char* nick)
 {
-       user_hash::iterator iter = clientlist->find(nick);
+       user_hash::iterator iter = this->Users->clientlist->find(nick);
 
-       if (iter == clientlist->end())
+       if (iter == this->Users->clientlist->end())
                return NULL;
 
        return iter->second;
@@ -254,9 +149,9 @@ User *InspIRCd::FindUUID(const std::string &uid)
 
 User *InspIRCd::FindUUID(const char *uid)
 {
-       user_hash::iterator finduuid = uuidlist->find(uid);
+       user_hash::iterator finduuid = this->Users->uuidlist->find(uid);
 
-       if (finduuid == uuidlist->end())
+       if (finduuid == this->Users->uuidlist->end())
                return NULL;
 
        return finduuid->second;
@@ -288,7 +183,7 @@ Channel* InspIRCd::FindChan(const std::string &chan)
 /* Send an error notice to all users, registered or not */
 void InspIRCd::SendError(const std::string &s)
 {
-       for (std::vector<User*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
+       for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
        {
                if ((*i)->registered == REG_ALL)
                {
@@ -307,17 +202,6 @@ void InspIRCd::SendError(const std::string &s)
        }
 }
 
-/* return how many users have a given mode e.g. 'a' */
-int InspIRCd::ModeCount(const char mode)
-{
-       ModeHandler* mh = this->Modes->FindMode(mode, MODETYPE_USER);
-
-       if (mh)
-               return mh->GetCount();
-       else
-               return 0;
-}
-
 /* return channel count */
 long InspIRCd::ChannelCount()
 {
index b77b5cc0ab26ceeb9a63a3758a06e2d511a0df41..7eb52ebc8f0451f5c5dc115caf238f96965f0168 100644 (file)
@@ -82,7 +82,7 @@ void InspIRCd::Cleanup()
        }
 
        /* Close all client sockets, or the new process inherits them */
-       for (std::vector<User*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
+       for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
        {
                (*i)->SetWriteError("Server shutdown");
                (*i)->CloseSocket();
@@ -156,21 +156,21 @@ void InspIRCd::ResetMaxBans()
  */
 void InspIRCd::RehashUsersAndChans()
 {
-       user_hash* old_users = this->clientlist;
-       user_hash* old_uuid  = this->uuidlist;
+       user_hash* old_users = this->Users->clientlist;
+       user_hash* old_uuid  = this->Users->uuidlist;
        chan_hash* old_chans = this->chanlist;
 
-       this->clientlist = new user_hash();
-       this->uuidlist = new user_hash();
+       this->Users->clientlist = new user_hash();
+       this->Users->uuidlist = new user_hash();
        this->chanlist = new chan_hash();
 
        for (user_hash::const_iterator n = old_users->begin(); n != old_users->end(); n++)
-               this->clientlist->insert(*n);
+               this->Users->clientlist->insert(*n);
 
        delete old_users;
 
        for (user_hash::const_iterator n = old_uuid->begin(); n != old_uuid->end(); n++)
-               this->uuidlist->insert(*n);
+               this->Users->uuidlist->insert(*n);
 
        delete old_uuid;
 
@@ -309,10 +309,10 @@ InspIRCd::InspIRCd(int argc, char** argv)
 
        this->s_signal = 0;
 
-       this->unregistered_count = 0;
+       this->Users->unregistered_count = 0;
 
-       this->clientlist = new user_hash();
-       this->uuidlist = new user_hash();
+       this->Users->clientlist = new user_hash();
+       this->Users->uuidlist = new user_hash();
        this->chanlist = new chan_hash();
 
        this->Res = NULL;
index d32bfb2125fc3e7469bce57e98f3b6e509b56fe1..758c02c20faa03c03c7cede7fd59c983e5447e28 100644 (file)
@@ -754,7 +754,7 @@ bool ModeParser::DelMode(ModeHandler* mh)
        switch (mh->GetModeType())
        {
                case MODETYPE_USER:
-                       for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++)
+                       for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++)
                        {
                                mh->RemoveMode(i->second);
                        }
index 622af02069c339bb0ebd3b7d71bfefed3a886621..5d8b68ae22296b94feed12a3afdebfec0c8491c0 100644 (file)
@@ -45,5 +45,5 @@ ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, st
 
 unsigned int ModeUserOperator::GetCount()
 {
-       return ServerInstance->all_opers.size();
+       return count;
 }
index cd869585f447bc6a34149df2e20ef43ba0b1fdcb..25a53fefed828d99a55c17f23f1427c82e7e901a 100644 (file)
@@ -512,7 +512,7 @@ bool ModuleManager::Unload(const char* filename)
                {
                        modfind->second.second->OnCleanup(TYPE_CHANNEL,c->second);
                }
-               for (user_hash::iterator u = Instance->clientlist->begin(); u != Instance->clientlist->end(); u++)
+               for (user_hash::iterator u = Instance->Users->clientlist->begin(); u != Instance->Users->clientlist->end(); u++)
                {
                        modfind->second.second->OnCleanup(TYPE_USER,u->second);
                }
index d3df1948b76e228cf296c75fd716eb596e8b4a25..7fea35d348638c86af47e7f97311bc6e9cb82d5a 100644 (file)
@@ -48,7 +48,7 @@ void RemoveData(User* who)
 
 void RemoveFromAllAccepts(InspIRCd* ServerInstance, User* who)
 {
-       for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); ++i)
+       for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); ++i)
        {
                callerid_data* dat = GetData(i->second, false);
                if (!dat) continue;
index cc8c7846bef1ac99000e097ea52e14cc250ed92f..af8aaa3fc74e9240fa8e822a05bf0accaf4147d7 100644 (file)
@@ -129,7 +129,7 @@ class CommandCheck : public Command
                        long x = 0;
 
                        /* hostname or other */
-                       for (user_hash::const_iterator a = ServerInstance->clientlist->begin(); a != ServerInstance->clientlist->end(); a++)
+                       for (user_hash::const_iterator a = ServerInstance->Users->clientlist->begin(); a != ServerInstance->Users->clientlist->end(); a++)
                        {
                                if (match(a->second->host, parameters[0]) || match(a->second->dhost, parameters[0]))
                                {
index 5d703c0d0221e7e559416e5ef2ade32018e8c4bd..9b868e61e9eccf1c04defaedb7766be7ec53bae6 100644 (file)
@@ -28,7 +28,7 @@ class CommandClose : public Command
        {
                std::map<std::string,int> closed;
 
-               for (std::vector<User*>::iterator u = ServerInstance->local_users.begin(); u != ServerInstance->local_users.end(); u++)
+               for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
                {
                        if ((*u)->registered != REG_ALL)
                        {
index de72dc339ff23409da48e0ed9df81ca4e4ed614c..63ddedcb87b51f020d4038838d12a72c81b5b293 100644 (file)
@@ -73,7 +73,7 @@ class ModuleHttpStats : public Module
                so->clear();
                for (StatsIter a = sh->begin(); a != sh->end(); a++)
                        InsertOrder(a->first, a->second);
-               for (user_hash::iterator u = ServerInstance->clientlist->begin(); u != ServerInstance->clientlist->end(); u++)
+               for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
                {
                        StatsHash::iterator n = Servers->find(u->second->server);
                        if (n != Servers->end())
@@ -103,9 +103,9 @@ class ModuleHttpStats : public Module
                                data << "<server><name>" << ServerInstance->Config->ServerName << "</name><gecos>" << ServerInstance->Config->ServerDesc << "</gecos></server>";
 
                                data << "<general>";
-                               data << "<usercount>" << ServerInstance->clientlist->size() << "</usercount>";
+                               data << "<usercount>" << ServerInstance->Users->clientlist->size() << "</usercount>";
                                data << "<channelcount>" << ServerInstance->chanlist->size() << "</channelcount>";
-                               data << "<opercount>" << ServerInstance->all_opers.size() << "</opercount>";
+                               data << "<opercount>" << ServerInstance->Users->all_opers.size() << "</opercount>";
                                data << "<socketcount>" << (ServerInstance->SE->GetMaxFds() - ServerInstance->SE->GetRemainingFds()) << "</socketcount><socketmax>" << ServerInstance->SE->GetMaxFds() <<
                                        "</socketmax><socketengine>" << ServerInstance->SE->GetName() << "</socketengine>";
 
index 30935c1dd4951cf96fcd781cab803ecbca3ceca3..3f816b3c0932f951e30452932f70d6943d94131e 100644 (file)
@@ -47,7 +47,7 @@ class InvisibleMode : public ModeHandler
 
        ~InvisibleMode()
        {
-               for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++)
+               for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++)
                        if (i->second->Visibility == qo)
                                i->second->Visibility = NULL;
                delete qo;
@@ -166,7 +166,7 @@ class ModuleInvisible : public Module
                        throw ModuleException("Could not add new mode watcher on usermode +o!");
 
                /* Yeah i know people can take this out. I'm not about to obfuscate code just to be a pain in the ass. */
-               ServerInstance->ServerNoticeAll("*** m_invisible.so has just been loaded on this network. For more information, please visit http://inspircd.org/wiki/Modules/invisible");
+               ServerInstance->Users->ServerNoticeAll("*** m_invisible.so has just been loaded on this network. For more information, please visit http://inspircd.org/wiki/Modules/invisible");
                Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserJoin, I_OnUserPart, I_OnUserQuit, I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, 6);
        }
index 86df623322eb2974de3d3c5268a00c352c2470ea..255d3eac95df198cefc4d3078dc302af14465066 100644 (file)
@@ -84,7 +84,7 @@ class CommandJumpserver : public Command
                if (redirect_all_immediately)
                {
                        /* Redirect everyone but the oper sending the command */
-                       for (std::vector<User*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
+                       for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
                        {
                                User* t = *i;
                                if (!IS_OPER(t))
index 270d7ef82ac9352dd39e8b5a181a843db51d6075..49684048941127874776f119db6178cf39109802 100644 (file)
@@ -64,7 +64,7 @@ ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
        };
        ServerInstance->Modules->Attach(eventlist, this, 29);
 
-       for (std::vector<User*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
+       for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
        {
                this->OnPostConnect((*i));
        }
@@ -150,8 +150,8 @@ void ModuleSpanningTree::HandleLusers(const char** parameters, int pcnt, User* u
                }
        }
        user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick,
-                       n_users-ServerInstance->ModeCount('i'),
-                       ServerInstance->ModeCount('i'),
+                       n_users-ServerInstance->Users->ModeCount('i'),
+                       ServerInstance->Users->ModeCount('i'),
                        ulined_count ? this->CountServs() - ulined_count : this->CountServs());
 
        if (ServerInstance->Users->OperCount())
index d50215b76c1480e4fe77f0d2877a9a5561f302ab..9b117272a3bcd292a6e93be86246c96d08467779 100644 (file)
@@ -66,14 +66,14 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, cha
                /* Neat and tidy default values, as we're dealing with a matrix not a simple string */
                memset(text, 0, 128);
 
-               if (ServerInstance->clientlist->size() == 0)
+               if (ServerInstance->Users->clientlist->size() == 0)
                {
                        // If there are no users, WHO THE HELL DID THE /MAP?!?!?!
                        percent = 0;
                }
                else
                {
-                       percent = ((float)Current->GetUserCount() / (float)ServerInstance->clientlist->size()) * 100;
+                       percent = ((float)Current->GetUserCount() / (float)ServerInstance->Users->clientlist->size()) * 100;
                }
 
                const std::string operdata = IS_OPER(user) ? MapOperInfo(Current) : "";
index 8b0f95b71005c7dbd0c59cf1a2d2037b5b6251b2..50b5d7949506748d677698101ea378b88d773f85 100644 (file)
@@ -150,7 +150,7 @@ int TreeServer::QuitUsers(const std::string &reason)
 {
        const char* reason_s = reason.c_str();
        std::vector<User*> time_to_die;
-       for (user_hash::iterator n = ServerInstance->clientlist->begin(); n != ServerInstance->clientlist->end(); n++)
+       for (user_hash::iterator n = ServerInstance->Users->clientlist->begin(); n != ServerInstance->Users->clientlist->end(); n++)
        {
                if (!strcmp(n->second->server, this->ServerName.c_str()))
                {
index 407717bde37140d219322d6e597a50770c9ba9c7..81a339f2efbb7529696783c9b13e1f68a7b11667 100644 (file)
@@ -1046,9 +1046,9 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa
 
 
        /* check for collision */
-       user_hash::iterator iter = this->Instance->clientlist->find(tempnick);
+       user_hash::iterator iter = this->Instance->Users->clientlist->find(tempnick);
 
-       if (iter != this->Instance->clientlist->end())
+       if (iter != this->Instance->Users->clientlist->end())
        {
                /*
                 * Nick collision.
@@ -1076,7 +1076,7 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa
                SendError("Protocol violation - Duplicate UUID '" + params[0] + "' on introduction of new user");
                return false;
        }
-       (*(this->Instance->clientlist))[tempnick] = _new;
+       (*(this->Instance->Users->clientlist))[tempnick] = _new;
        _new->SetFd(FD_MAGIC_NUMBER);
        strlcpy(_new->nick, tempnick, NICKMAX - 1);
        strlcpy(_new->host, params[3].c_str(),64);
@@ -1267,7 +1267,7 @@ void TreeSocket::SendUsers(TreeServer* Current)
        char data[MAXBUF];
        std::deque<std::string> list;
        std::string dataline;
-       for (user_hash::iterator u = this->Instance->clientlist->begin(); u != this->Instance->clientlist->end(); u++)
+       for (user_hash::iterator u = this->Instance->Users->clientlist->begin(); u != this->Instance->Users->clientlist->end(); u++)
        {
                if (u->second->registered == REG_ALL)
                {
index 7c2df1e2a2fea4c4bd2ec976f965354061fdbebc..28f66f0d2e3e40cfa233c36af2628206e43396b3 100644 (file)
@@ -242,7 +242,7 @@ bool TreeSocket::OperType(const std::string &prefix, std::deque<std::string> &pa
        if (u)
        {
                if (!u->IsModeSet('o'))
-                       this->Instance->all_opers.push_back(u);
+                       this->Instance->Users->all_opers.push_back(u);
                u->modes[UM_OPERATOR] = 1;
                strlcpy(u->oper,opertype.c_str(),NICKMAX-1);
                Utils->DoOneToAllButSender(u->nick,"OPERTYPE",params,u->server);
@@ -1073,7 +1073,7 @@ bool TreeSocket::ProcessLine(std::string &line)
                
                if (prefix.empty())
                {
-                       this->SendError("BUG (??) Empty prefix recieved.");
+                       this->SendError("BUG (?) Empty prefix recieved.");
                        return false;
                }
        }
@@ -1480,7 +1480,7 @@ bool TreeSocket::ProcessLine(std::string &line)
                                        sourceserv = this->InboundServerName;
                                if (params.size() >= 2)
                                {
-                                       Instance->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", prefix.c_str(), params[1].c_str());
+                                       Instance->Users->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", prefix.c_str(), params[1].c_str());
                                }
                                return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
                        }
index 06941c168da2ec38d4a1f61996c35e7501f3d5b7..28a3d2f69945929ed2bb980acf1ece2de11d7621 100644 (file)
@@ -34,7 +34,7 @@ class CommandTline : public Command
                float n_match_host = 0;
                float n_match_ip = 0;
 
-               for (user_hash::const_iterator u = ServerInstance->clientlist->begin(); u != ServerInstance->clientlist->end(); u++)
+               for (user_hash::const_iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
                {
                        n_counted++;
                        if (match(u->second->GetFullRealHost(),parameters[0]))
index 3154d3ec0aa41c1f7532a81c1339955c66552dd7..32c77e99f6ce5a18018ba9f7c84bc7d0cf466ee7 100644 (file)
@@ -125,7 +125,7 @@ void Snomask::Flush()
        ServerInstance->Log(DEBUG, "Flusing snomask %s", this->Description.c_str());
 
        /* Only opers can receive snotices, so we iterate the oper list */
-       for (std::list<User*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
+       for (std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); i++)
        {
                User* a = *i;
                if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(MySnomask) && !a->quitting)
index 1917c780e3c73d11f2d25d00dcc771e63919d983..5ee84590b8b1b667733420927e6ad3fde743a958 100644 (file)
@@ -39,7 +39,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac
 
        int j = 0;
 
-       Instance->unregistered_count++;
+       this->unregistered_count++;
 
        char ipaddr[MAXBUF];
 #ifdef IPV6
@@ -49,7 +49,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac
 #endif
        inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr));
 
-       (*(Instance->clientlist))[New->uuid] = New;
+       (*(this->clientlist))[New->uuid] = New;
 
        /* The users default nick is their UUID */
        strlcpy(New->nick, New->uuid, NICKMAX - 1);
@@ -92,9 +92,9 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac
         */
        New->CheckClass();
 
-       Instance->local_users.push_back(New);
+       this->local_users.push_back(New);
 
-       if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
+       if ((this->local_users.size() > Instance->Config->SoftLimit) || (this->local_users.size() >= MAXCLIENTS))
        {
                Instance->SNO->WriteToSnoMask('A', "Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit);
                User::QuitUser(Instance, New,"No more connections allowed");
@@ -243,32 +243,148 @@ unsigned int UserManager::UserCount()
         *  As part of this restructuring, move clientlist/etc fields into usermanager.
         *      -- w00t
         */
-       return ServerInstance->clientlist->size();
+       return this->clientlist->size();
 }
 
 /* this counts only registered users, so that the percentages in /MAP don't mess up */
 unsigned int UserManager::RegisteredUserCount()
 {
-       return ServerInstance->clientlist->size() - this->UnregisteredUserCount();
+       return this->clientlist->size() - this->UnregisteredUserCount();
 }
 
 /* return how many users are opered */
 unsigned int UserManager::OperCount()
 {
-       return ServerInstance->all_opers.size();
+       return this->all_opers.size();
 }
 
 /* return how many users are unregistered */
 unsigned int UserManager::UnregisteredUserCount()
 {
-       return ServerInstance->unregistered_count;
+       return this->unregistered_count;
 }
 
 /* return how many local registered users there are */
 unsigned int UserManager::LocalUserCount()
 {
        /* Doesnt count unregistered clients */
-       return (ServerInstance->local_users.size() - this->UnregisteredUserCount());
+       return (this->local_users.size() - this->UnregisteredUserCount());
 }
 
+void UserManager::ServerNoticeAll(char* text, ...)
+{
+       if (!text)
+               return;
+
+       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 :%s", ServerInstance->Config->ServerName, textbuffer);
+
+       for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+       {
+               User* t = *i;
+               t->WriteServ(std::string(formatbuffer));
+       }
+}
+
+void UserManager::ServerPrivmsgAll(char* text, ...)
+{
+       if (!text)
+               return;
+
+       char textbuffer[MAXBUF];
+       char formatbuffer[MAXBUF];
+       va_list argsPtr;
+       va_start (argsPtr, text);
+       vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+       va_end(argsPtr);
+
+       snprintf(formatbuffer,MAXBUF,"PRIVMSG $%s :%s", ServerInstance->Config->ServerName, textbuffer);
+
+       for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+       {
+               User* t = *i;
+               t->WriteServ(std::string(formatbuffer));
+       }
+}
+
+void UserManager::WriteMode(const char* modes, int flags, const char* text, ...)
+{
+       char textbuffer[MAXBUF];
+       int modelen;
+       va_list argsPtr;
+
+       if (!text || !modes || !flags)
+       {
+               ServerInstance->Log(DEFAULT,"*** BUG *** WriteMode was given an invalid parameter");
+               return;
+       }
+
+       va_start(argsPtr, text);
+       vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+       va_end(argsPtr);
+       modelen = strlen(modes);
+
+       if (flags == WM_AND)
+       {
+               for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+               {
+                       User* t = *i;
+                       bool send_to_user = true;
+
+                       for (int n = 0; n < modelen; n++)
+                       {
+                               if (!t->IsModeSet(modes[n]))
+                               {
+                                       send_to_user = false;
+                                       break;
+                               }
+                       }
+                       if (send_to_user)
+                       {
+                               t->WriteServ("NOTICE %s :%s", t->nick, textbuffer);
+                       }
+               }
+       }
+       else if (flags == WM_OR)
+       {
+               for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+               {
+                       User* t = *i;
+                       bool send_to_user = false;
+
+                       for (int n = 0; n < modelen; n++)
+                       {
+                               if (t->IsModeSet(modes[n]))
+                               {
+                                       send_to_user = true;
+                                       break;
+                               }
+                       }
+
+                       if (send_to_user)
+                       {
+                               t->WriteServ("NOTICE %s :%s", t->nick, textbuffer);
+                       }
+               }
+       }
+}
+
+/* return how many users have a given mode e.g. 'a' */
+int UserManager::ModeCount(const char mode)
+{
+       ModeHandler* mh = this->ServerInstance->Modes->FindMode(mode, MODETYPE_USER);
+
+       if (mh)
+               return mh->GetCount();
+       else
+               return 0;
+}
+
+
 
index 5ec2581f7a72b5c730c0448bb1aad750e7e188a1..dd1ca179981c2a3e59cc97dbece77220667ff940 100644 (file)
@@ -167,7 +167,7 @@ void InspIRCd::DoBackgroundUserStuff()
        /*
         * loop over all local users..
         */
-       for (std::vector<User*>::iterator count2 = local_users.begin(); count2 != local_users.end(); count2++)
+       for (std::vector<User*>::iterator count2 = this->Users->local_users.begin(); count2 != this->Users->local_users.end(); count2++)
        {
                User *curr = *count2;
 
index 731f5a603a1c66e3f4cf1ce6b7b92014fca90abf..6b2aebfc7466380b12a2649897e857ff56d1c43d 100644 (file)
@@ -205,9 +205,9 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
 
        ServerInstance->Log(DEBUG,"New UUID for user: %s (%s)", uuid, uid.empty() ? "allocated new" : "used remote");
 
-       user_hash::iterator finduuid = Instance->uuidlist->find(uuid);
-       if (finduuid == Instance->uuidlist->end())
-               (*Instance->uuidlist)[uuid] = this;
+       user_hash::iterator finduuid = Instance->Users->uuidlist->find(uuid);
+       if (finduuid == Instance->Users->uuidlist->end())
+               (*Instance->Users->uuidlist)[uuid] = this;
        else
                throw CoreException("Duplicate UUID "+std::string(uuid)+" in User constructor");
 }
@@ -245,7 +245,7 @@ User::~User()
 #endif
        }
 
-       ServerInstance->uuidlist->erase(uuid);
+       ServerInstance->Users->uuidlist->erase(uuid);
 }
 
 char* User::MakeHost()
@@ -636,7 +636,7 @@ void User::Oper(const std::string &opertype, const std::string &opername)
                FOREACH_MOD(I_OnOper, OnOper(this, opertype));
                ServerInstance->Log(DEFAULT,"OPER: %s!%s@%s opered as type: %s", this->nick, this->ident, this->host, opertype.c_str());
                strlcpy(this->oper, opertype.c_str(), NICKMAX - 1);
-               ServerInstance->all_opers.push_back(this);
+               ServerInstance->Users->all_opers.push_back(this);
 
                opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper);
                if (iter_opertype != ServerInstance->Config->opertypes.end())
@@ -688,7 +688,7 @@ void User::UnOper()
                        this->modes[UM_OPERATOR] = 0;
                        
                        // remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404
-                       ServerInstance->all_opers.remove(this);
+                       ServerInstance->Users->all_opers.remove(this);
 
                        if (AllowedOperCommands)
                        {
@@ -811,8 +811,8 @@ void User::FullConnect()
        this->ShowMOTD();
 
        /* Now registered */
-       if (ServerInstance->unregistered_count)
-               ServerInstance->unregistered_count--;
+       if (ServerInstance->Users->unregistered_count)
+               ServerInstance->Users->unregistered_count--;
 
        /* Trigger LUSERS output, give modules a chance too */
        int MOD_RESULT = 0;
@@ -845,17 +845,17 @@ User* User::UpdateNickHash(const char* New)
        try
        {
                //user_hash::iterator newnick;
-               user_hash::iterator oldnick = ServerInstance->clientlist->find(this->nick);
+               user_hash::iterator oldnick = ServerInstance->Users->clientlist->find(this->nick);
 
                if (!strcasecmp(this->nick,New))
                        return oldnick->second;
 
-               if (oldnick == ServerInstance->clientlist->end())
+               if (oldnick == ServerInstance->Users->clientlist->end())
                        return NULL; /* doesnt exist */
 
                User* olduser = oldnick->second;
-               (*(ServerInstance->clientlist))[New] = olduser;
-               ServerInstance->clientlist->erase(oldnick);
+               (*(ServerInstance->Users->clientlist))[New] = olduser;
+               ServerInstance->Users->clientlist->erase(oldnick);
                return olduser;
        }
 
@@ -1312,7 +1312,7 @@ void User::WriteWallOps(const std::string &text)
        std::string wallop("WALLOPS :");
        wallop.append(text);
 
-       for (std::vector<User*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
+       for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
        {
                User* t = *i;
                if (t->IsModeSet('w'))
@@ -1456,7 +1456,7 @@ void User::SendAll(const char* command, char* text, ...)
        snprintf(formatbuffer,MAXBUF,":%s %s $* :%s", this->GetFullHost(), command, textbuffer);
        std::string fmt = formatbuffer;
 
-       for (std::vector<User*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
+       for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
        {
                (*i)->Write(fmt);
        }
index 20df92dd0003503989ceed3997ff7210eb21abc4..268804f9dce804981a14f4f9e700e6746ffef23b 100644 (file)
@@ -70,7 +70,7 @@ void XLineManager::CheckELines()
        if (ELines.empty())
                return;
 
-       for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
+       for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
        {
                User* u = (User*)(*u2);
 
@@ -203,7 +203,7 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User*
 void ELine::Unset()
 {
        /* remove exempt from everyone and force recheck after deleting eline */
-       for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
+       for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
        {
                User* u = (User*)(*u2);
                u->exempt = false;
@@ -310,7 +310,7 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item)
 // applies lines, removing clients and changing nicks etc as applicable
 void XLineManager::ApplyLines()
 {
-       for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
+       for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
        {
                User* u = (User*)(*u2);
 
@@ -536,7 +536,7 @@ bool GLine::Matches(const std::string &str)
 void ELine::OnAdd()
 {
        /* When adding one eline, only check the one eline */
-       for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
+       for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
        {
                User* u = (User*)(*u2);
                if (this->Matches(u))