]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
FindNick, FindChan, ChanModes, UserList, CountInvisible, PurgeEmptyChannels, GetClass...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 10 Aug 2006 14:43:29 +0000 (14:43 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 10 Aug 2006 14:43:29 +0000 (14:43 +0000)
ServerConfig takes InspIRCd pointer in its constructor

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4832 e03df62e-2008-0410-955e-edbf42e46eb7

88 files changed:
include/channels.h
include/configreader.h
include/globals.h
include/helperfuncs.h
include/inspircd.h
include/inspstring.h
include/modules.h
include/users.h
src/channels.cpp
src/cmd_die.cpp
src/cmd_eline.cpp
src/cmd_gline.cpp
src/cmd_invite.cpp
src/cmd_ison.cpp
src/cmd_kick.cpp
src/cmd_kill.cpp
src/cmd_kline.cpp
src/cmd_list.cpp
src/cmd_loadmodule.cpp
src/cmd_names.cpp
src/cmd_nick.cpp
src/cmd_notice.cpp
src/cmd_oper.cpp
src/cmd_part.cpp
src/cmd_pass.cpp
src/cmd_privmsg.cpp
src/cmd_qline.cpp
src/cmd_quit.cpp
src/cmd_rehash.cpp
src/cmd_restart.cpp
src/cmd_server.cpp
src/cmd_stats.cpp
src/cmd_topic.cpp
src/cmd_unloadmodule.cpp
src/cmd_userhost.cpp
src/cmd_who.cpp
src/cmd_whois.cpp
src/cmd_zline.cpp
src/commands.cpp
src/configreader.cpp
src/helperfuncs.cpp
src/inspircd.cpp
src/inspstring.cpp
src/mode.cpp
src/modes/cmode_b.cpp
src/modes/cmode_h.cpp
src/modes/cmode_o.cpp
src/modes/cmode_v.cpp
src/modules.cpp
src/modules/extra/m_sqlauth.cpp
src/modules/m_alias.cpp
src/modules/m_blockamsg.cpp
src/modules/m_cban.cpp
src/modules/m_cgiirc.cpp
src/modules/m_chanprotect.cpp
src/modules/m_check.cpp
src/modules/m_chghost.cpp
src/modules/m_chgident.cpp
src/modules/m_connflood.cpp
src/modules/m_filter.cpp
src/modules/m_globalload.cpp
src/modules/m_httpd_stats.cpp
src/modules/m_knock.cpp
src/modules/m_nicklock.cpp
src/modules/m_operlevels.cpp
src/modules/m_override.cpp
src/modules/m_park.cpp
src/modules/m_redirect.cpp
src/modules/m_remove.cpp
src/modules/m_safelist.cpp
src/modules/m_sajoin.cpp
src/modules/m_samode.cpp
src/modules/m_sanick.cpp
src/modules/m_sapart.cpp
src/modules/m_saquit.cpp
src/modules/m_sethost.cpp
src/modules/m_setident.cpp
src/modules/m_setidle.cpp
src/modules/m_spanningtree.cpp
src/modules/m_spy.cpp
src/modules/m_swhois.cpp
src/modules/m_timedbans.cpp
src/modules/m_uninvite.cpp
src/modules/m_userip.cpp
src/modules/m_watch.cpp
src/userprocess.cpp
src/users.cpp
src/xline.cpp

index 32f28c75177a43d94dd33839b0a020b1a24fbacb..e9dcfb1336cf5f859ca565c59c68fb417420be61 100644 (file)
@@ -428,6 +428,14 @@ class chanrec : public Extensible
         */
        void WriteAllExceptSender(userrec* user, char status, const std::string& text);
 
+       long GetMaxBans();
+
+       char* ChanModes(bool showkey);
+
+       void UserList(userrec *user);
+
+       int CountInvisible();
+
        /** Destructor for chanrec
         */
        virtual ~chanrec() { /* stub */ }
index 79384c2dbc8f2839833195266d674fe6869fad2f..5bf26e69523ff024678d894d461f6b722ade2f02 100644 (file)
@@ -27,6 +27,7 @@
 #include "modules.h"
 
 class ServerConfig;
+class InspIRCd;
 
 typedef bool (*Validator)(ServerConfig* conf, const char*, const char*, void*);
 typedef bool (*MultiValidator)(ServerConfig* conf, const char*, char**, void**, int*);
@@ -61,6 +62,8 @@ struct MultiConfig
 class ServerConfig : public Extensible
 {
   private:
+       InspIRCd* ServerInstance;
+
        /** This variable holds the names of all
         * files included from the main one. This
         * is used to make sure that no files are
@@ -354,7 +357,7 @@ class ServerConfig : public Extensible
         */
        bool SyntaxHints;
 
-       ServerConfig();
+       ServerConfig(InspIRCd* Instance);
 
        /** Clears the include stack in preperation for
         * a Read() call.
index 9950db422e3b050c0cc90b51ce1efdafbbea6cc8..d30f18edea57dffd095b0bd20b464be90724404a 100644 (file)
@@ -31,8 +31,6 @@ typedef std::pair< std::string, std::string > KeyVal;
 typedef std::vector< KeyVal > KeyValList;
 typedef std::multimap< std::string, KeyValList > ConfigDataHash;
 
-void WriteOpers(char* text, ...);
 int isnick(const char *n);
-chanrec* FindChan(const char* chan);
 
 #endif
index 801e05bdb625d859d37eb1132d931f6481d05ea3..9c3207a9eaa857fe4277706ef0edfe6fc552263d 100644 (file)
@@ -48,20 +48,7 @@ enum DebugLevel
 #define STRINGIFY(x) STRINGIFY2(x) 
 #define log(l, x, args...) InspIRCd::Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args)
 
-void WriteOpers(const char* text, ...);
-void WriteOpers_NoFormat(const char* text);
-
-std::string GetServerDescription(const char* servername);
 void strlower(char *n);
-userrec* Find(const std::string &nick);
-userrec* Find(const char* nick);
-chanrec* FindChan(const char* chan);
-int usercount_i(chanrec *c);
-long GetMaxBans(char* name);
-void purge_empty_chans(userrec* u);
-char* chanmodes(chanrec *chan, bool showkey);
-void userlist(userrec *user,chanrec *c);
-ConnectClass GetClass(userrec *user);
 void Error(int status);
 void ShowMOTD(userrec *user);
 void ShowRULES(userrec *user);
@@ -73,7 +60,4 @@ std::string GetFullProgDir(char** argv, int argc);
 int InsertMode(std::string &output, const char* modes, unsigned short section);
 bool IsValidChannelName(const char *);
 
-int charlcat(char* x,char y,int z);
-bool charremove(char* mp, char remove);
-
 #endif
index 7cd1d973d1ca4b3f5ffe60a3bb46844e545a64bd..94bba27f6ecf3bad8492b3eb9f832d60abfb369c 100644 (file)
@@ -122,6 +122,17 @@ class InspIRCd : public classbase
        const char* FindServerNamePtr(const std::string &servername);
        bool FindServerName(const std::string &servername);
 
+       std::string GetServerDescription(const char* servername);
+
+       void WriteOpers(const char* text, ...);
+       void WriteOpers(const std::string &text);
+       
+       userrec* FindNick(const std::string &nick);
+       userrec* FindNick(const char* nick);
+
+       chanrec* FindChan(const std::string &chan);
+       chanrec* FindChan(const char* chan);
+
        bool UserToPseudo(userrec* user, const std::string &message);
        bool PseudoToUser(userrec* alive, userrec* zombie, const std::string &message);
 
index c5a20e9e4509e5c79691c069b052fb557dd542bd..b294121000c30cfc7d2e0824dfd8a097ccfff526 100644 (file)
@@ -9,4 +9,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
 size_t strlcat(char *dst, const char *src, size_t siz);
 #endif
 
+int charlcat(char* x,char y,int z);
+bool charremove(char* mp, char remove);
+
 #endif
index aca4f06ea21eedfa6ef96a5c6806c56615c119b7..fca1bc128a4bee58d2691a5abcd08ecdc916c1bd 100644 (file)
@@ -1297,11 +1297,6 @@ class Server : public Extensible
         * @returns a priority ID which the core uses to relocate the module in the list
         */
        long PriorityAfter(const std::string &modulename);
-       
-       /** Sends text to all opers.
-        * This method sends a server notice to all opers with the usermode +s.
-        */
-       virtual void SendOpers(const std::string &s);
 
        /** Returns the version string of this server
         */
@@ -1357,21 +1352,11 @@ class Server : public Extensible
         */
        virtual bool IsNick(const std::string &nick);
 
-       /** Attempts to look up a nick and return a pointer to it.
-        * This function will return NULL if the nick does not exist.
-        */
-       virtual userrec* FindNick(const std::string &nick);
-
        /** Attempts to look up a nick using the file descriptor associated with that nick.
         * This function will return NULL if the file descriptor is not associated with a valid user.
         */
        virtual userrec* FindDescriptor(int socket);
 
-       /** Attempts to look up a channel and return a pointer to it.
-        * This function will return NULL if the channel does not exist.
-        */
-       virtual chanrec* FindChannel(const std::string &channel);
-
        /** Attempts to look up a user's privilages on a channel.
         * This function will return a string containing either @, %, +, or an empty string,
         * representing the user's privilages upon the channel you specify.
index 1d8e918aa2b88dd11915a2951b900cad0dc44574..165b74aa4a1624065e80a47f0eb11925316b95ed 100644 (file)
@@ -650,6 +650,10 @@ class userrec : public connection
 
        void SplitChanList(userrec* dest, const std::string &cl);
 
+       void PurgeEmptyChannels();
+
+       ConnectClass& GetClass();
+
        /** Default destructor
         */
        virtual ~userrec();
index d50841de7e7e0858d96c73a56556072ca0341ae5..a78b926428650ada612eee18e12c4074d21c896a 100644 (file)
@@ -224,7 +224,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo
        int MOD_RESULT = 0;
        strlcpy(cname,cn,CHANMAX);
 
-       chanrec* Ptr = FindChan(cname);
+       chanrec* Ptr = Instance->FindChan(cname);
 
        if (!Ptr)
        {
@@ -455,7 +455,7 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr,ucrec *a,userrec* u
                        user->WriteServ("332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
                        user->WriteServ("333 %s %s %s %lu", user->nick, Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset);
                }
-               userlist(user,Ptr);
+               Ptr->UserList(user);
                user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, Ptr->name);
        }
        FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user,Ptr));
@@ -739,3 +739,145 @@ void chanrec::WriteAllExceptSender(userrec* user, char status, const std::string
        }
 }
 
+/*
+ * return a count of the users on a specific channel accounting for
+ * invisible users who won't increase the count. e.g. for /LIST
+ */
+int chanrec::CountInvisible()
+{
+       int count = 0;
+       CUList *ulist= this->GetUsers();
+       for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+       {
+               if (!(i->second->modes[UM_INVISIBLE]))
+                       count++;
+       }
+
+       return count;
+}
+
+char* chanrec::ChanModes(bool showkey)
+{
+       static char scratch[MAXBUF];
+       static char sparam[MAXBUF];
+       char* offset = scratch;
+       std::string extparam = "";
+
+       *scratch = '\0';
+       *sparam = '\0';
+
+       /* This was still iterating up to 190, chanrec::custom_modes is only 64 elements -- Om */
+       for(int n = 0; n < 64; n++)
+       {
+               if(this->modes[n])
+               {
+                       *offset++ = n + 65;
+                       extparam = "";
+                       switch (n)
+                       {
+                               case CM_KEY:
+                                       extparam = (showkey ? this->key : "<key>");
+                               break;
+                               case CM_LIMIT:
+                                       extparam = ConvToStr(this->limit);
+                               break;
+                               case CM_NOEXTERNAL:
+                               case CM_TOPICLOCK:
+                               case CM_INVITEONLY:
+                               case CM_MODERATED:
+                               case CM_SECRET:
+                               case CM_PRIVATE:
+                                       /* We know these have no parameters */
+                               break;
+                               default:
+                                       extparam = this->GetModeParameter(n + 65);
+                               break;
+                       }
+                       if (extparam != "")
+                       {
+                               charlcat(sparam,' ',MAXBUF);
+                               strlcat(sparam,extparam.c_str(),MAXBUF);
+                       }
+               }
+       }
+
+       /* Null terminate scratch */
+       *offset = '\0';
+       strlcat(scratch,sparam,MAXBUF);
+       return scratch;
+}
+
+/* compile a userlist of a channel into a string, each nick seperated by
+ * spaces and op, voice etc status shown as @ and +, and send it to 'user'
+ */
+void chanrec::UserList(userrec *user)
+{
+       char list[MAXBUF];
+       size_t dlen, curlen;
+
+       dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, this->name);
+
+       int numusers = 0;
+       char* ptr = list + dlen;
+
+       CUList *ulist= this->GetUsers();
+
+       /* Improvement by Brain - this doesnt change in value, so why was it inside
+        * the loop?
+        */
+       bool has_user = this->HasUser(user);
+
+       for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+       {
+               if ((!has_user) && (i->second->modes[UM_INVISIBLE]))
+               {
+                       /*
+                        * user is +i, and source not on the channel, does not show
+                        * nick in NAMES list
+                        */
+                       continue;
+               }
+
+               size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", cmode(i->second, this), i->second->nick);
+
+               curlen += ptrlen;
+               ptr += ptrlen;
+
+               numusers++;
+
+               if (curlen > (480-NICKMAX))
+               {
+                       /* list overflowed into multiple numerics */
+                       user->WriteServ(list);
+
+                       /* reset our lengths */
+                       dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, this->name);
+                       ptr = list + dlen;
+
+                       ptrlen = 0;
+                       numusers = 0;
+               }
+       }
+
+       /* if whats left in the list isnt empty, send it */
+       if (numusers)
+       {
+               user->WriteServ(list);
+       }
+}
+
+long chanrec::GetMaxBans()
+{
+       std::string x;
+       for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
+       {
+               x = n->first;
+               if (match(this->name,x.c_str()))
+               {
+                       return n->second;
+               }
+       }
+       return 64;
+}
+
+
index 93b9f498795c64e904eeca88d80a51935f497f2a..366173758e9f1a5f9b8e408648397d756ddb9e84 100644 (file)
@@ -53,6 +53,6 @@ void cmd_die::Handle (const char** parameters, int pcnt, userrec *user)
        else
        {
                log(SPARSE, "Failed /DIE command from %s!%s@%s", user->nick, user->ident, user->host);
-               WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);
+               ServerInstance->WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);
        }
 }
index 4c674f26231bb8bd911b0188432afbc0ef9a999e..e2679fc14a8a0d35b24a589216af4b592c7743da 100644 (file)
@@ -41,11 +41,11 @@ void cmd_eline::Handle (const char** parameters, int pcnt, userrec *user)
 
                if (!duration(parameters[1]))
                {
-                       WriteOpers("*** %s added permanent E-line for %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s added permanent E-line for %s.",user->nick,parameters[0]);
                }
                else
                {
-                       WriteOpers("*** %s added timed E-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+                       ServerInstance->WriteOpers("*** %s added timed E-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
                }
        }
        else
@@ -53,7 +53,7 @@ void cmd_eline::Handle (const char** parameters, int pcnt, userrec *user)
                if (del_eline(parameters[0]))
                {
                        FOREACH_MOD(I_OnDelELine,OnDelELine(user, parameters[0]));
-                       WriteOpers("*** %s Removed E-line on %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s Removed E-line on %s.",user->nick,parameters[0]);
                }
                else
                {
index 2b774fb1d284bad080907a798d7bdcf925376068..ea526f8c81397b860c56453c314cda5e954816c2 100644 (file)
@@ -41,11 +41,11 @@ void cmd_gline::Handle (const char** parameters, int pcnt, userrec *user)
 
                if (!duration(parameters[1]))
                {
-                       WriteOpers("*** %s added permanent G-line for %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s added permanent G-line for %s.",user->nick,parameters[0]);
                }
                else
                {
-                       WriteOpers("*** %s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+                       ServerInstance->WriteOpers("*** %s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
                }
 
                apply_lines(APPLY_GLINES);
@@ -55,7 +55,7 @@ void cmd_gline::Handle (const char** parameters, int pcnt, userrec *user)
                if (del_gline(parameters[0]))
                {
                        FOREACH_MOD(I_OnDelGLine,OnDelGLine(user, parameters[0]));
-                       WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]);
                }
                else
                {
index 0255c23dd4659f6021d5ed16bb4f44c2a2f4ebb3..78de20cd89e4a1d53f484171c51be02b1e65dc68 100644 (file)
@@ -34,8 +34,8 @@ void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user)
 
        if (pcnt == 2)
        {
-               userrec* u = Find(parameters[0]);
-               chanrec* c = FindChan(parameters[1]);
+               userrec* u = ServerInstance->FindNick(parameters[0]);
+               chanrec* c = ServerInstance->FindChan(parameters[1]);
 
                if ((!c) || (!u))
                {
index 0b0ec24a50d262a37e665e4f5e9e35293c20df9a..1fefeab1c08140b367732432e515ce3250ca0fe6 100644 (file)
 #include "users.h"
 #include "commands.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 #include "commands/cmd_ison.h"
 
+extern InspIRCd* ServerInstance;
+
 void cmd_ison::Handle (const char** parameters, int pcnt, userrec *user)
 {
        char retbuf[MAXBUF];
@@ -30,7 +33,7 @@ void cmd_ison::Handle (const char** parameters, int pcnt, userrec *user)
 
        for (int i = 0; i < pcnt; i++)
        {
-               u = Find(parameters[i]);
+               u = ServerInstance->FindNick(parameters[i]);
 
                if (u)
                {
index 042c6c02d0a5441f4b32ec7ca18b2fce5b6bbc0a..5c03921b6bade53c0a726903003a78bf55e81937 100644 (file)
 #include "users.h"
 #include "commands.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 #include "commands/cmd_kick.h"
 
+extern InspIRCd* ServerInstance;
+
 void cmd_kick::Handle (const char** parameters, int pcnt, userrec *user)
 {
        char reason[MAXKICK];
-       chanrec* c = FindChan(parameters[0]);
-       userrec* u = Find(parameters[1]);
+       chanrec* c = ServerInstance->FindChan(parameters[0]);
+       userrec* u = ServerInstance->FindNick(parameters[1]);
 
        if (!u || !c)
        {
index 22525e8cf63a60aad703c1859fd456c9aa285b0a..86a014267ace4f861cef96a44f84ebf62a5da697 100644 (file)
@@ -31,7 +31,7 @@ extern std::vector<ircd_module*> factory;
 
 void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
 {
-       userrec *u = Find(parameters[0]);
+       userrec *u = ServerInstance->FindNick(parameters[0]);
        char killreason[MAXBUF];
        int MOD_RESULT = 0;
 
@@ -51,7 +51,7 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
                if (!IS_LOCAL(u))
                {
                        // remote kill
-                       WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
+                       ServerInstance->WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
                        snprintf(killreason, MAXQUIT,"[%s] Killed (%s (%s))", ServerInstance->Config->ServerName, user->nick, parameters[1]);
                        u->WriteCommonExcept("QUIT :%s", killreason);
                        FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason));
@@ -66,7 +66,7 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
 
                        if (u->registered == REG_ALL)
                        {
-                               purge_empty_chans(u);
+                               u->PurgeEmptyChannels();
                        }
 
                        DELETE(u);
@@ -76,7 +76,7 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
                        // local kill
                        log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
                        user->WriteTo(u, "KILL %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
-                       WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
+                       ServerInstance->WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
                        snprintf(killreason,MAXQUIT,"Killed (%s (%s))", user->nick, parameters[1]);
                        userrec::QuitUser(ServerInstance, u, killreason);
                }
index 3feb15d10e516ea6aa4372573d300699918a9858..5bdba041dfe05d71962f09208b69d1dbb2b6b1d8 100644 (file)
@@ -49,11 +49,11 @@ void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user)
 
                if (!duration(parameters[1]))
                {
-                       WriteOpers("*** %s added permanent K-line for %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s added permanent K-line for %s.",user->nick,parameters[0]);
                }
                else
                {
-                       WriteOpers("*** %s added timed K-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+                       ServerInstance->WriteOpers("*** %s added timed K-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
                }
 
                apply_lines(APPLY_KLINES);
@@ -63,7 +63,7 @@ void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user)
                if (del_kline(parameters[0]))
                {
                        FOREACH_MOD(I_OnDelKLine,OnDelKLine(user, parameters[0]));
-                       WriteOpers("*** %s Removed K-line on %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s Removed K-line on %s.",user->nick,parameters[0]);
                }
                else
                {
index 3dbb3c2e28864b6a4bd1abcf23afecf746097f0d..ded20d077bc9bbcc34652a531ab80470f93c8bad 100644 (file)
@@ -34,7 +34,7 @@ void cmd_list::Handle (const char** parameters, int pcnt, userrec *user)
                {
                        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);
+                               user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,users,i->second->ChanModes(n),i->second->topic);
                }
        }
        user->WriteServ("323 %s :End of channel list.",user->nick);
index ace2debf7ec316f159e3d46424692b8a21828488..bef24f3217a8217679a9026c84236c8aa62fa45f 100644 (file)
@@ -26,7 +26,7 @@ void cmd_loadmodule::Handle (const char** parameters, int pcnt, userrec *user)
 {
        if (ServerInstance->LoadModule(parameters[0]))
        {
-               WriteOpers("*** NEW MODULE: %s",parameters[0]);
+               ServerInstance->WriteOpers("*** NEW MODULE: %s",parameters[0]);
                user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
        }
        else
index 318846d1328775ef828b3fa524483ecadd8c642f..0ce00e4ba4c44139ae1f702d3dcec7885c3ae3da 100644 (file)
@@ -35,7 +35,7 @@ void cmd_names::Handle (const char** parameters, int pcnt, userrec *user)
        if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
                return;
 
-       c = FindChan(parameters[0]);
+       c = ServerInstance->FindChan(parameters[0]);
        if (c)
        {
                if ((c->modes[CM_SECRET]) && (!c->HasUser(user)))
@@ -43,7 +43,7 @@ void cmd_names::Handle (const char** parameters, int pcnt, userrec *user)
                      user->WriteServ("401 %s %s :No such nick/channel",user->nick, c->name);
                      return;
                }
-               userlist(user,c);
+               c->UserList(user);
                user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, c->name);
        }
        else
index b0810a2e54ab4993fcd0d1034bc7b0f0d8a2952a..9313899f74573c93907086f817881c3782a25023 100644 (file)
@@ -92,11 +92,11 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
                }
                if (matches_qline(parameters[0]))
                {
-                       WriteOpers("*** Q-Lined nickname %s from %s!%s@%s: %s",parameters[0],user->nick,user->ident,user->host,matches_qline(parameters[0]));
+                       ServerInstance->WriteOpers("*** Q-Lined nickname %s from %s!%s@%s: %s",parameters[0],user->nick,user->ident,user->host,matches_qline(parameters[0]));
                        user->WriteServ("432 %s %s :Invalid nickname: %s",user->nick,parameters[0],matches_qline(parameters[0]));
                        return;
                }
-               if ((Find(parameters[0])) && (Find(parameters[0]) != user))
+               if ((ServerInstance->FindNick(parameters[0])) && (ServerInstance->FindNick(parameters[0]) != user))
                {
                        user->WriteServ("433 %s %s :Nickname is already in use.",user->nick,parameters[0]);
                        return;
index f1e814198ddf0acf97d65a1471363a69daa8a1c5..6825ea5ead2deb8a5e2ec152ce6e74d6835513bc 100644 (file)
@@ -69,7 +69,7 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
        }
        if (*parameters[0] == '#')
        {
-               chan = FindChan(parameters[0]);
+               chan = ServerInstance->FindChan(parameters[0]);
                if (chan)
                {
                        if (IS_LOCAL(user))
@@ -113,7 +113,7 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
                return;
        }
        
-       dest = Find(parameters[0]);
+       dest = ServerInstance->FindNick(parameters[0]);
        if (dest)
        {
                int MOD_RESULT = 0;
index 7fa598934614688fc2beedcd2fbc484195b53436..085b6983d84bbbe0b3ac5272d3bbeecab5a174b8 100644 (file)
@@ -97,7 +97,7 @@ void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
                                        if (!isnick(TypeName))
                                        {
                                                user->WriteServ("491 %s :Invalid oper type (oper types must follow the same syntax as nicknames)",user->nick);
-                                               WriteOpers("*** CONFIGURATION ERROR! Oper type invalid for OperType '%s'",OperType);
+                                               ServerInstance->WriteOpers("*** CONFIGURATION ERROR! Oper type invalid for OperType '%s'",OperType);
                                                log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type erroneous.",user->nick,user->ident,user->host);
                                                return;
                                        }
@@ -113,7 +113,7 @@ void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
        if (found)
        {
                /* correct oper credentials */
-               WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
+               ServerInstance->WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
                user->WriteServ("381 %s :You are now an IRC operator of type %s",user->nick,OperType);
                if (!user->modes[UM_OPERATOR])
                        user->Oper(OperType);
@@ -123,13 +123,13 @@ void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
                if (!fail2)
                {
                        user->WriteServ("491 %s :Invalid oper credentials",user->nick);
-                       WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
+                       ServerInstance->WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
                        log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: user, host or password did not match.",user->nick,user->ident,user->host);
                }
                else
                {
                        user->WriteServ("491 %s :Your oper block does not have a valid opertype associated with it",user->nick);
-                       WriteOpers("*** CONFIGURATION ERROR! Oper block mismatch for OperType %s",OperType);
+                       ServerInstance->WriteOpers("*** CONFIGURATION ERROR! Oper block mismatch for OperType %s",OperType);
                        log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host);
                }
        }
index beb590ab9412e788700762471899221470aed9b2..88aab1abf06416ba4a58f068fa3d83d4f22b5894 100644 (file)
@@ -27,7 +27,7 @@ void cmd_part::Handle (const char** parameters, int pcnt, userrec *user)
        if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
                return;
 
-       chanrec* c = FindChan(parameters[0]);
+       chanrec* c = ServerInstance->FindChan(parameters[0]);
        
        if (c)
        {
index 7abb7f2ab581f294c62619759c1aa5a947aad518..35a65b3c536bbda2a14b6ef0cdcc251488d9dfca 100644 (file)
@@ -27,7 +27,7 @@ void cmd_pass::Handle (const char** parameters, int pcnt, userrec *user)
                user->WriteServ("462 %s :You may not reregister",user->nick);
                return;
        }
-       ConnectClass a = GetClass(user);
+       ConnectClass a = user->GetClass();
        strlcpy(user->password,parameters[0],63);
        if (!strcmp(parameters[0],a.pass.c_str()))
        {
index 8a2175ecc67e59b68ba9f612fcdce6f9dab2c27b..e72e1ef757ac6d606cc368cc492e57f7c546663d 100644 (file)
@@ -67,7 +67,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
        }
        if (parameters[0][0] == '#')
        {
-               chan = FindChan(parameters[0]);
+               chan = ServerInstance->FindChan(parameters[0]);
                if (chan)
                {
                        if (IS_LOCAL(user))
@@ -109,7 +109,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
                return;
        }
 
-       dest = Find(parameters[0]);
+       dest = ServerInstance->FindNick(parameters[0]);
        if (dest)
        {
                if ((IS_LOCAL(user)) && (*dest->awaymsg))
index e38c0288041a6b3439eef62182bef5e685908afa..1452a065821197d84837f58c3b2e0dc7fbb8ebf5 100644 (file)
@@ -38,11 +38,11 @@ void cmd_qline::Handle (const char** parameters, int pcnt, userrec *user)
                FOREACH_MOD(I_OnAddQLine,OnAddQLine(duration(parameters[1]), user, parameters[2], parameters[0]));
                if (!duration(parameters[1]))
                {
-                       WriteOpers("*** %s added permanent Q-line for %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s added permanent Q-line for %s.",user->nick,parameters[0]);
                }
                else
                {
-                       WriteOpers("*** %s added timed Q-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+                       ServerInstance->WriteOpers("*** %s added timed Q-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
                }
                apply_lines(APPLY_QLINES);
        }
@@ -51,7 +51,7 @@ void cmd_qline::Handle (const char** parameters, int pcnt, userrec *user)
                if (del_qline(parameters[0]))
                {
                        FOREACH_MOD(I_OnDelQLine,OnDelQLine(user, parameters[0]));
-                       WriteOpers("*** %s Removed Q-line on %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s Removed Q-line on %s.",user->nick,parameters[0]);
                }
                else
                {
index feaab0fe4b413f342ec5058c2199ed747ae3b48a..3673b842710c141bfb2703f7b005a707bc8327d8 100644 (file)
@@ -62,12 +62,12 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
                        if (user->fd > -1)
                        {
                                user->Write("ERROR :Closing link (%s@%s) [%s%s]",user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]);
-                               WriteOpers("*** Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]);
+                               ServerInstance->WriteOpers("*** Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]);
                                user->WriteCommonExcept("QUIT :%s%s",ServerInstance->Config->PrefixQuit,parameters[0]);
                        }
                        else
                        {
-                               WriteOpers("*** Client exiting at %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,parameters[0]);
+                               ServerInstance->WriteOpers("*** Client exiting at %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,parameters[0]);
                                user->WriteCommonExcept("QUIT :%s",parameters[0]);
                        }
                        FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,std::string(ServerInstance->Config->PrefixQuit)+std::string(parameters[0])));
@@ -76,7 +76,7 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
                else
                {
                        user->Write("ERROR :Closing link (%s@%s) [QUIT]",user->ident,user->host);
-                       WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host);
+                       ServerInstance->WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host);
                        user->WriteCommonExcept("QUIT :Client exited");
                        FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,"Client exited"));
 
@@ -104,7 +104,7 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
        }
 
        if (user->registered == REG_ALL) {
-               purge_empty_chans(user);
+               user->PurgeEmptyChannels();
        }
        if (user->fd > -1)
                ServerInstance->fd_ref_table[user->fd] = NULL;
index b452a8d0c12354572659d3c77f9f9e54b17851c9..eeb8958f9b6955f478178acff24fb6b71e472e46 100644 (file)
@@ -37,7 +37,7 @@ void cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user)
        }
        else
        {
-               WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
+               ServerInstance->WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
                ServerInstance->Config->Read(false,user);
        }
        FOREACH_MOD(I_OnRehash,OnRehash(parameter));
index 81c45386f826c5fadb865d6bfdcf9f3375390cfe..318a8ee312087aaa38deb5c6a81d192d92e7f148 100644 (file)
@@ -28,7 +28,7 @@ void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
        log(DEFAULT,"Restart: %s",user->nick);
        if (!strcmp(parameters[0],ServerInstance->Config->restartpass))
        {
-               WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
+               ServerInstance->WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
 
                argv[0] = ServerInstance->Config->MyExecutable;
                argv[1] = "-wait";
@@ -58,6 +58,6 @@ void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
        }
        else
        {
-               WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
+               ServerInstance->WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
        }
 }
index bd41e55958aa7b369af3dda3f25b2e61bab21a43..93274e040570461164709f2471acdbc8c6fae9da 100644 (file)
 #include "users.h"
 #include "commands.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 #include "commands/cmd_server.h"
 
+extern InspIRCd* ServerInstance;
+
 void cmd_server::Handle (const char** parameters, int pcnt, userrec *user)
 {
        user->WriteServ("666 %s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick);
-       WriteOpers("*** WARNING: %s attempted to issue a SERVER command and is registered as a user!",user->nick);
+       ServerInstance->WriteOpers("*** WARNING: %s attempted to issue a SERVER command and is registered as a user!",user->nick);
 }
index 6f124d6eb0f7ed1918a4007b03633d2b90678b1f..194b8b24c29ebb853f603f36f5beb7b9d2679659 100644 (file)
@@ -260,7 +260,7 @@ void DoStats(char statschar, userrec* user, string_list &results)
        }
 
        results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
-       WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
+       ServerInstance->WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
 
        return;
 }
index 913b80dd3fe377635847bb19ce907fd2007e4449..bd7308f2648bf561d327835385a05894570efc52 100644 (file)
@@ -35,7 +35,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
 
        if (pcnt == 1)
        {
-               Ptr = FindChan(parameters[0]);
+               Ptr = ServerInstance->FindChan(parameters[0]);
                if (Ptr)
                {
                        if ((Ptr->modes[CM_SECRET]) && (!Ptr->HasUser(user)))
@@ -61,7 +61,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
        }
        else if (pcnt>1)
        {
-               Ptr = FindChan(parameters[0]);
+               Ptr = ServerInstance->FindChan(parameters[0]);
                if (Ptr)
                {
                        if (IS_LOCAL(user))
index ca1667d1a1999bcea39ec3fa008031212a22cf14..70cf2c6986a0e2022ec7cbe7aa11224cf305645d 100644 (file)
@@ -26,7 +26,7 @@ void cmd_unloadmodule::Handle (const char** parameters, int pcnt, userrec *user)
 {
        if (ServerInstance->UnloadModule(parameters[0]))
        {
-               WriteOpers("*** MODULE UNLOADED: %s",parameters[0]);
+               ServerInstance->WriteOpers("*** MODULE UNLOADED: %s",parameters[0]);
                user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
        }
        else
index 49a81c402bc44dcaf0e3747cb8aae0832144e5d4..64210b57ad3c62fb942e119cdc1097fe4f66062e 100644 (file)
 #include "users.h"
 #include "commands.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 #include "commands/cmd_userhost.h"
 
+extern InspIRCd* ServerInstance;
+
 void cmd_userhost::Handle (const char** parameters, int pcnt, userrec *user)
 {
        char Return[MAXBUF],junk[MAXBUF];
@@ -27,7 +30,7 @@ void cmd_userhost::Handle (const char** parameters, int pcnt, userrec *user)
        
        for (int i = 0; i < pcnt; i++)
        {
-               userrec *u = Find(parameters[i]);
+               userrec *u = ServerInstance->FindNick(parameters[i]);
                if(u)
                {
                        if(*u->oper)
index de3f30196fae2fc5fb9a5aaa02f250d3ff4681ce..140fa92e2906b2c29dbf3b0dcb8719064756cc89 100644 (file)
@@ -115,7 +115,7 @@ void cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
 
 
        /* who on a channel? */
-       ch = FindChan(matchtext);
+       ch = ServerInstance->FindChan(matchtext);
 
        if (ch)
        {
index 5f980750bc9d3c10c4308b56704ab1b62c291040..09e8eea65c47dae0a525ff548ece3565f6d5305f 100644 (file)
@@ -24,7 +24,7 @@
 #include "commands/cmd_whois.h"
 
 extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
+
 extern int MODCOUNT;
 extern ModuleList modules;
 extern FactoryList factory;
@@ -68,7 +68,7 @@ void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long i
                }
                else
                {
-                       user->WriteServ("312 %s %s %s :%s",user->nick, dest->nick, dest->server, GetServerDescription(dest->server).c_str());
+                       user->WriteServ("312 %s %s %s :%s",user->nick, dest->nick, dest->server, ServerInstance->GetServerDescription(dest->server).c_str());
                }
                if (*dest->awaymsg)
                {
@@ -107,7 +107,7 @@ void cmd_whois::Handle (const char** parameters, int pcnt, userrec *user)
        if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
                return;
 
-       dest = Find(parameters[0]);
+       dest = ServerInstance->FindNick(parameters[0]);
        if (dest)
        {
                do_whois(user,dest,0,0,parameters[0]);
@@ -119,3 +119,4 @@ void cmd_whois::Handle (const char** parameters, int pcnt, userrec *user)
                user->WriteServ("318 %s %s :End of /WHOIS list.",user->nick, parameters[0]);
        }
 }
+
index cb838b2de45dc483793a9e03374592544ff307dc..ab068479ee63d9bab63eb0a3f2b1890f208bffb5 100644 (file)
@@ -44,11 +44,11 @@ void cmd_zline::Handle (const char** parameters, int pcnt, userrec *user)
                FOREACH_MOD(I_OnAddZLine,OnAddZLine(duration(parameters[1]), user, parameters[2], parameters[0]));
                if (!duration(parameters[1]))
                {
-                       WriteOpers("*** %s added permanent Z-line for %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s added permanent Z-line for %s.",user->nick,parameters[0]);
                }
                else
                {
-                       WriteOpers("*** %s added timed Z-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+                       ServerInstance->WriteOpers("*** %s added timed Z-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
                }
                apply_lines(APPLY_ZLINES);
        }
@@ -57,7 +57,7 @@ void cmd_zline::Handle (const char** parameters, int pcnt, userrec *user)
                if (del_zline(parameters[0]))
                {
                        FOREACH_MOD(I_OnDelZLine,OnDelZLine(user, parameters[0]));
-                       WriteOpers("*** %s Removed Z-line on %s.",user->nick,parameters[0]);
+                       ServerInstance->WriteOpers("*** %s Removed Z-line on %s.",user->nick,parameters[0]);
                }
                else
                {
index b1eb5149078c9e586d3c64f4c10788ced61fd904..8a7e38204c4dea41ccd35303b567b8912e10d86a 100644 (file)
@@ -209,7 +209,7 @@ bool host_matches_everyone(const std::string &mask, userrec* user)
        float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100;
        if (percent > (float)atof(itrigger))
        {
-               WriteOpers("*** \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);
+               ServerInstance->WriteOpers("*** \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);
                return true;
        }
        return false;
@@ -235,7 +235,7 @@ bool ip_matches_everyone(const std::string &ip, userrec* user)
        float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100;
        if (percent > (float)atof(itrigger))
        {
-               WriteOpers("*** \2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent);
+               ServerInstance->WriteOpers("*** \2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent);
                return true;
        }
        return false;
@@ -261,7 +261,7 @@ bool nick_matches_everyone(const std::string &nick, userrec* user)
        float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100;
        if (percent > (float)atof(itrigger))
        {
-               WriteOpers("*** \2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent);
+               ServerInstance->WriteOpers("*** \2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent);
                return true;
        }
        return false;
index 0b712ca6c93388c754d6961aaf3f2a772f7511c4..1843878908f4198a4c9150444bb131e3481887e6 100644 (file)
@@ -27,7 +27,6 @@
 #include "userprocess.h"
 #include "xline.h"
 
-extern InspIRCd* ServerInstance;
 extern time_t TIME;
 
 extern int MODCOUNT;
@@ -38,7 +37,7 @@ using irc::sockets::BindPorts;
 
 std::vector<std::string> old_module_names, new_module_names, added_modules, removed_modules;
 
-ServerConfig::ServerConfig()
+ServerConfig::ServerConfig(InspIRCd* Instance) : ServerInstance(Instance)
 {
        this->ClearStack();
        *TempDir = *ServerName = *Network = *ServerDesc = *AdminName = '\0';
@@ -116,8 +115,8 @@ bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user)
                        }
                        else
                        {
-                               WriteOpers("There were errors in the configuration file:");
-                               WriteOpers("You have more than one <%s> tag, this is not permitted.\n",tag);
+                               ServerInstance->WriteOpers("There were errors in the configuration file:");
+                               ServerInstance->WriteOpers("You have more than one <%s> tag, this is not permitted.\n",tag);
                        }
                }
                return false;
@@ -138,8 +137,8 @@ bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user)
                        }
                        else
                        {
-                               WriteOpers("There were errors in the configuration file:");
-                               WriteOpers("You have not defined a <%s> tag, this is required.",tag);
+                               ServerInstance->WriteOpers("There were errors in the configuration file:");
+                               ServerInstance->WriteOpers("You have not defined a <%s> tag, this is required.",tag);
                        }
                }
                return false;
@@ -285,20 +284,20 @@ bool ValidateServerName(ServerConfig* conf, const char* tag, const char* value,
 
 bool ValidateNetBufferSize(ServerConfig* conf, const char* tag, const char* value, void* data)
 {
-       if ((!ServerInstance->Config->NetBufferSize) || (ServerInstance->Config->NetBufferSize > 65535) || (ServerInstance->Config->NetBufferSize < 1024))
+       if ((!conf->NetBufferSize) || (conf->NetBufferSize > 65535) || (conf->NetBufferSize < 1024))
        {
                log(DEFAULT,"No NetBufferSize specified or size out of range, setting to default of 10240.");
-               ServerInstance->Config->NetBufferSize = 10240;
+               conf->NetBufferSize = 10240;
        }
        return true;
 }
 
 bool ValidateMaxWho(ServerConfig* conf, const char* tag, const char* value, void* data)
 {
-       if ((!ServerInstance->Config->MaxWhoResults) || (ServerInstance->Config->MaxWhoResults > 65535) || (ServerInstance->Config->MaxWhoResults < 1))
+       if ((!conf->MaxWhoResults) || (conf->MaxWhoResults > 65535) || (conf->MaxWhoResults < 1))
        {
                log(DEFAULT,"No MaxWhoResults specified or size out of range, setting to default of 128.");
-               ServerInstance->Config->MaxWhoResults = 128;
+               conf->MaxWhoResults = 128;
        }
        return true;
 }
@@ -306,32 +305,32 @@ bool ValidateMaxWho(ServerConfig* conf, const char* tag, const char* value, void
 bool ValidateLogLevel(ServerConfig* conf, const char* tag, const char* value, void* data)
 {
        const char* dbg = (const char*)data;
-       ServerInstance->Config->LogLevel = DEFAULT;
+       conf->LogLevel = DEFAULT;
        if (!strcmp(dbg,"debug"))
        {
-               ServerInstance->Config->LogLevel = DEBUG;
-               ServerInstance->Config->debugging = 1;
+               conf->LogLevel = DEBUG;
+               conf->debugging = 1;
        }
        else if (!strcmp(dbg,"verbose"))
-               ServerInstance->Config->LogLevel = VERBOSE;
+               conf->LogLevel = VERBOSE;
        else if (!strcmp(dbg,"default"))
-               ServerInstance->Config->LogLevel = DEFAULT;
+               conf->LogLevel = DEFAULT;
        else if (!strcmp(dbg,"sparse"))
-               ServerInstance->Config->LogLevel = SPARSE;
+               conf->LogLevel = SPARSE;
        else if (!strcmp(dbg,"none"))
-               ServerInstance->Config->LogLevel = NONE;
+               conf->LogLevel = NONE;
        return true;
 }
 
 bool ValidateMotd(ServerConfig* conf, const char* tag, const char* value, void* data)
 {
-       conf->ReadFile(ServerInstance->Config->MOTD,ServerInstance->Config->motd);
+       conf->ReadFile(conf->MOTD,conf->motd);
        return true;
 }
 
 bool ValidateRules(ServerConfig* conf, const char* tag, const char* value, void* data)
 {
-       conf->ReadFile(ServerInstance->Config->RULES,ServerInstance->Config->rules);
+       conf->ReadFile(conf->RULES,conf->rules);
        return true;
 }
 
@@ -340,7 +339,7 @@ bool ValidateRules(ServerConfig* conf, const char* tag, const char* value, void*
 bool InitConnect(ServerConfig* conf, const char* tag)
 {
        log(DEFAULT,"Reading connect classes...");
-       ServerInstance->Config->Classes.clear();
+       conf->Classes.clear();
        return true;
 }
 
@@ -394,13 +393,13 @@ bool DoConnect(ServerConfig* conf, const char* tag, char** entries, void** value
                        c.registration_timeout = 90;
                if (c.pingtime == 0)
                        c.pingtime = 120;
-               ServerInstance->Config->Classes.push_back(c);
+               conf->Classes.push_back(c);
        }
        else
        {
                c.host = deny;
                c.type = CC_DENY;
-               ServerInstance->Config->Classes.push_back(c);
+               conf->Classes.push_back(c);
                log(DEBUG,"Read connect class type DENY, host=%s",deny);
        }
 
@@ -419,7 +418,7 @@ bool DoneConnect(ServerConfig* conf, const char* tag)
  */
 bool InitULine(ServerConfig* conf, const char* tag)
 {
-       ServerInstance->Config->ulines.clear();
+       conf->ulines.clear();
        return true;
 }
 
@@ -429,7 +428,7 @@ bool DoULine(ServerConfig* conf, const char* tag, char** entries, void** values,
 {
        char* server = (char*)values[0];
        log(DEBUG,"Read ULINE '%s'",server);
-       ServerInstance->Config->ulines.push_back(server);
+       conf->ulines.push_back(server);
        return true;
 }
 
@@ -448,7 +447,7 @@ bool InitModule(ServerConfig* conf, const char* tag)
        new_module_names.clear();
        added_modules.clear();
        removed_modules.clear();
-       for (std::vector<std::string>::iterator t = ServerInstance->Config->module_names.begin(); t != ServerInstance->Config->module_names.end(); t++)
+       for (std::vector<std::string>::iterator t = conf->module_names.begin(); t != conf->module_names.end(); t++)
        {
                old_module_names.push_back(*t);
        }
@@ -503,7 +502,7 @@ bool DoneModule(ServerConfig* conf, const char* tag)
  */
 bool InitMaxBans(ServerConfig* conf, const char* tag)
 {
-       ServerInstance->Config->maxbans.clear();
+       conf->maxbans.clear();
        return true;
 }
 
@@ -513,7 +512,7 @@ bool DoMaxBans(ServerConfig* conf, const char* tag, char** entries, void** value
 {
        char* channel = (char*)values[0];
        int* limit = (int*)values[1];
-       ServerInstance->Config->maxbans[channel] = *limit;
+       conf->maxbans[channel] = *limit;
        return true;
 }
 
@@ -694,11 +693,11 @@ void ServerConfig::Read(bool bail, userrec* user)
                        }
                        else
                        {
-                               WriteOpers("There were errors in the configuration file:");
+                               ServerInstance->WriteOpers("There were errors in the configuration file:");
                                
                                while(start < errors.length())
                                {
-                                       WriteOpers(errors.substr(start, 360).c_str());
+                                       ServerInstance->WriteOpers(errors.substr(start, 360).c_str());
                                        start += 360;
                                }
                        }
@@ -809,7 +808,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                        {
                                if (ServerInstance->UnloadModule(removing->c_str()))
                                {
-                                       WriteOpers("*** REHASH UNLOADED MODULE: %s",removing->c_str());
+                                       ServerInstance->WriteOpers("*** REHASH UNLOADED MODULE: %s",removing->c_str());
 
                                        if (user)
                                                user->WriteServ("973 %s %s :Module %s successfully unloaded.",user->nick, removing->c_str(), removing->c_str());
@@ -828,7 +827,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                {
                        if (ServerInstance->LoadModule(adding->c_str()))
                        {
-                               WriteOpers("*** REHASH LOADED MODULE: %s",adding->c_str());
+                               ServerInstance->WriteOpers("*** REHASH LOADED MODULE: %s",adding->c_str());
 
                                if (user)
                                        user->WriteServ("975 %s %s :Module %s successfully loaded.",user->nick, adding->c_str(), adding->c_str());
index 1f2a6646b5ea838ef952f77feaa25dad8656ab50..8bfba1ca5f2c3aedc70b92ca98827c03fc8779e1 100644 (file)
@@ -102,7 +102,7 @@ void InspIRCd::Log(int level, const std::string &text)
        }
 }
 
-std::string GetServerDescription(const char* servername)
+std::string InspIRCd::GetServerDescription(const char* servername)
 {
        std::string description = "";
 
@@ -115,7 +115,7 @@ std::string GetServerDescription(const char* servername)
        else
        {
                // not a remote server that can be found, it must be me.
-               return ServerInstance->Config->ServerDesc;
+               return Config->ServerDesc;
        }
 }
 
@@ -126,43 +126,27 @@ std::string GetServerDescription(const char* servername)
  * uses the oper list, which means if you have 2000 users but only 5 opers,
  * it iterates 5 times.
  */
-void WriteOpers(const char* text, ...)
+void InspIRCd::WriteOpers(const char* text, ...)
 {
        char textbuffer[MAXBUF];
        va_list argsPtr;
 
-       if (!text)
-       {
-               log(DEFAULT,"*** BUG *** WriteOpers was given an invalid parameter");
-               return;
-       }
-
        va_start(argsPtr, text);
        vsnprintf(textbuffer, MAXBUF, text, argsPtr);
        va_end(argsPtr);
 
-       WriteOpers_NoFormat(textbuffer);
+       this->WriteOpers(std::string(textbuffer));
 }
 
-void WriteOpers_NoFormat(const char* text)
+void InspIRCd::WriteOpers(const std::string &text)
 {
-       if (!text)
-       {
-               log(DEFAULT,"*** BUG *** WriteOpers_NoFormat was given an invalid parameter");
-               return;
-       }
-
        for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++)
        {
                userrec* a = *i;
-
-               if (IS_LOCAL(a))
+               if (IS_LOCAL(a) && a->modes[UM_SERVERNOTICE])
                {
-                       if (a->modes[UM_SERVERNOTICE])
-                       {
-                               // send server notices to all with +s
-                               a->WriteServ("NOTICE %s :%s",a->nick,text);
-                       }
+                       // send server notices to all with +s
+                       a->WriteServ("NOTICE %s :%s",a->nick,text.c_str());
                }
        }
 }
@@ -285,27 +269,27 @@ void strlower(char *n)
 
 /* Find a user record by nickname and return a pointer to it */
 
-userrec* Find(const std::string &nick)
+userrec* InspIRCd::FindNick(const std::string &nick)
 {
-       user_hash::iterator iter = ServerInstance->clientlist.find(nick);
+       user_hash::iterator iter = clientlist.find(nick);
 
-       if (iter == ServerInstance->clientlist.end())
+       if (iter == clientlist.end())
                /* Couldn't find it */
                return NULL;
 
        return iter->second;
 }
 
-userrec* Find(const char* nick)
+userrec* InspIRCd::FindNick(const char* nick)
 {
        user_hash::iterator iter;
 
        if (!nick)
                return NULL;
 
-       iter = ServerInstance->clientlist.find(nick);
+       iter = clientlist.find(nick);
        
-       if (iter == ServerInstance->clientlist.end())
+       if (iter == clientlist.end())
                return NULL;
 
        return iter->second;
@@ -313,239 +297,33 @@ userrec* Find(const char* nick)
 
 /* find a channel record by channel name and return a pointer to it */
 
-chanrec* FindChan(const char* chan)
+chanrec* InspIRCd::FindChan(const char* chan)
 {
        chan_hash::iterator iter;
 
        if (!chan)
-       {
-               log(DEFAULT,"*** BUG *** Findchan was given an invalid parameter");
                return NULL;
-       }
 
-       iter = ServerInstance->chanlist.find(chan);
+       iter = chanlist.find(chan);
 
-       if (iter == ServerInstance->chanlist.end())
+       if (iter == chanlist.end())
                /* Couldn't find it */
                return NULL;
 
        return iter->second;
 }
 
-
-long GetMaxBans(char* name)
-{
-       std::string x;
-       for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
-       {
-               x = n->first;
-               if (match(name,x.c_str()))
-               {
-                       return n->second;
-               }
-       }
-       return 64;
-}
-
-void purge_empty_chans(userrec* u)
-{
-       std::vector<chanrec*> to_delete;
-
-       // firstly decrement the count on each channel
-       for (std::vector<ucrec*>::iterator f = u->chans.begin(); f != u->chans.end(); f++)
-       {
-               ucrec* uc = (ucrec*)(*f);
-               if (uc->channel)
-               {
-                       if (uc->channel->DelUser(u) == 0)
-                       {
-                               /* No users left in here, mark it for deletion */
-                               to_delete.push_back(uc->channel);
-                               uc->channel = NULL;
-                       }
-               }
-       }
-
-       log(DEBUG,"purge_empty_chans: %d channels to delete",to_delete.size());
-
-       for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
-       {
-               chanrec* thischan = (chanrec*)*n;
-               chan_hash::iterator i2 = ServerInstance->chanlist.find(thischan->name);
-               if (i2 != ServerInstance->chanlist.end())
-               {
-                       FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
-                       DELETE(i2->second);
-                       ServerInstance->chanlist.erase(i2);
-               }
-       }
-
-       u->UnOper();
-}
-
-
-char* chanmodes(chanrec *chan, bool showkey)
-{
-       static char scratch[MAXBUF];
-       static char sparam[MAXBUF];
-       char* offset = scratch;
-       std::string extparam = "";
-
-       if (!chan)
-       {
-               log(DEFAULT,"*** BUG *** chanmodes was given an invalid parameter");
-               *scratch = '\0';
-               return scratch;
-       }
-
-       *scratch = '\0';
-       *sparam = '\0';
-
-       /* This was still iterating up to 190, chanrec::custom_modes is only 64 elements -- Om */
-       for(int n = 0; n < 64; n++)
-       {
-               if(chan->modes[n])
-               {
-                       *offset++ = n+65;
-                       extparam = "";
-                       switch (n)
-                       {
-                               case CM_KEY:
-                                       extparam = (showkey ? chan->key : "<key>");
-                               break;
-                               case CM_LIMIT:
-                                       extparam = ConvToStr(chan->limit);
-                               break;
-                               case CM_NOEXTERNAL:
-                               case CM_TOPICLOCK:
-                               case CM_INVITEONLY:
-                               case CM_MODERATED:
-                               case CM_SECRET:
-                               case CM_PRIVATE:
-                                       /* We know these have no parameters */
-                               break;
-                               default:
-                                       extparam = chan->GetModeParameter(n+65);
-                               break;
-                       }
-                       if (extparam != "")
-                       {
-                               charlcat(sparam,' ',MAXBUF);
-                               strlcat(sparam,extparam.c_str(),MAXBUF);
-                       }
-               }
-       }
-
-       /* Null terminate scratch */
-       *offset = '\0';
-       strlcat(scratch,sparam,MAXBUF);
-       return scratch;
-}
-
-
-/* compile a userlist of a channel into a string, each nick seperated by
- * spaces and op, voice etc status shown as @ and + */
-
-void userlist(userrec *user,chanrec *c)
-{
-       if ((!c) || (!user))
-       {
-               log(DEFAULT,"*** BUG *** userlist was given an invalid parameter");
-               return;
-       }
-
-       char list[MAXBUF];
-       size_t dlen, curlen;
-
-       dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
-
-       int numusers = 0;
-       char* ptr = list + dlen;
-
-       CUList *ulist= c->GetUsers();
-
-       /* Improvement by Brain - this doesnt change in value, so why was it inside
-        * the loop?
-        */
-       bool has_user = c->HasUser(user);
-
-       for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
-       {
-               if ((!has_user) && (i->second->modes[UM_INVISIBLE]))
-               {
-                       /*
-                        * user is +i, and source not on the channel, does not show
-                        * nick in NAMES list
-                        */
-                       continue;
-               }
-
-               size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", cmode(i->second, c), i->second->nick);
-
-               curlen += ptrlen;
-               ptr += ptrlen;
-
-               numusers++;
-
-               if (curlen > (480-NICKMAX))
-               {
-                       /* list overflowed into multiple numerics */
-                       user->WriteServ(list);
-
-                       /* reset our lengths */
-                       dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
-                       ptr = list + dlen;
-
-                       ptrlen = 0;
-                       numusers = 0;
-               }
-       }
-
-       /* if whats left in the list isnt empty, send it */
-       if (numusers)
-       {
-               user->WriteServ(list);
-       }
-}
-
-/*
- * return a count of the users on a specific channel accounting for
- * invisible users who won't increase the count. e.g. for /LIST
- */
-int usercount_i(chanrec *c)
+chanrec* InspIRCd::FindChan(const std::string &chan)
 {
-       int count = 0;
-
-       if (!c)
-               return 0;
+       chan_hash::iterator iter = chanlist.find(chan);
 
-       CUList *ulist= c->GetUsers();
-       for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
-       {
-               if (!(i->second->modes[UM_INVISIBLE]))
-                       count++;
-       }
+       if (iter == chanlist.end())
+               /* Couldn't find it */
+               return NULL;
 
-       return count;
+       return iter->second;
 }
 
-/* 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,
- * <connect allow="127.0.0.1"> will match joe!bloggs@localhost
- */
-ConnectClass GetClass(userrec *user)
-{
-       for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
-       {
-               if ((match(user->GetIPString(),i->host.c_str(),true)) || (match(user->host,i->host.c_str())))
-               {
-                       return *i;
-               }
-       }
-
-       return *(ServerInstance->Config->Classes.begin());
-}
 
 /*
  * sends out an error notice to all connected clients (not to be used
@@ -590,7 +368,7 @@ void Error(int status)
                log(DEFAULT,"[%d] %s", i, strings[i]);
        }
        free(strings);
-       WriteOpers("*** SIGSEGV: Please see the ircd.log for backtrace and report the error to http://www.inspircd.org/bugtrack/");
+       ServerInstance->WriteOpers("*** SIGSEGV: Please see the ircd.log for backtrace and report the error to http://www.inspircd.org/bugtrack/");
 #else
        log(DEFAULT,"You do not have execinfo.h so i could not backtrace -- on FreeBSD, please install the libexecinfo port.");
 #endif
@@ -902,42 +680,6 @@ bool IsValidChannelName(const char *chname)
        return true;
 }
 
-inline int charlcat(char* x,char y,int z)
-{
-       char* x__n = x;
-       int v = 0;
-
-       while(*x__n++)
-               v++;
-
-       if (v < z - 1)
-       {
-               *--x__n = y;
-               *++x__n = 0;
-       }
-
-       return v;
-}
-
-bool charremove(char* mp, char remove)
-{
-       char* mptr = mp;
-       bool shift_down = false;
-
-       while (*mptr)
-       {
-               if (*mptr == remove)
-               shift_down = true;
-
-               if (shift_down)
-                       *mptr = *(mptr+1);
-
-               mptr++;
-       }
-
-       return shift_down;
-}
-
 void OpenLog(char** argv, int argc)
 {
        if (!*LOG_FILE)
index 9f38eec7e4f2f96b0f84484aab865573295a91af..7d5cf6dc573e67db0e61e07a37cf010998fd3ce2 100644 (file)
@@ -142,7 +142,7 @@ void Killed(int status)
 
 void Rehash(int status)
 {
-       WriteOpers("Rehashing config file %s due to SIGHUP",CleanFilename(CONFIG_FILE));
+       ServerInstance->WriteOpers("Rehashing config file %s due to SIGHUP",CleanFilename(CONFIG_FILE));
        fclose(ServerInstance->Config->log_file);
        OpenLog(NULL,0);
        ServerInstance->Config->Read(false,NULL);
@@ -228,8 +228,8 @@ void InspIRCd::MakeLowerMap()
 InspIRCd::InspIRCd(int argc, char** argv)
 {
        bool SEGVHandler = false;
-       this->Config = new ServerConfig;
        ServerInstance = this;
+       this->Config = new ServerConfig(this);
        this->Start();
        this->module_sockets.clear();
        this->startup_time = time(NULL);
@@ -304,7 +304,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
        Config->Read(true, NULL);
        CheckRoot();
        this->ModeGrok = new ModeParser();
-       AddServerName(Config->ServerName);
+       this->AddServerName(Config->ServerName);
        CheckDie();
        InitializeDisabledCommands(Config->DisabledCommands, this);
        stats->BoundPortCount = BindPorts(true);
index 4f1875b8c870ee728d86c254ac832b2c6508a7f8..71aed43ba68113840363c5159b1d2bc38ba78802 100644 (file)
@@ -74,7 +74,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz)
     do
     {
       if ((*d++ = *s++) == 0)
-        break;
+       break;
     } while (--n != 0);
   }
 
@@ -90,3 +90,40 @@ size_t strlcpy(char *dst, const char *src, size_t siz)
   return(s - src - 1); /* count does not include NUL */
 }
 #endif
+
+int charlcat(char* x,char y,int z)
+{
+       char* x__n = x;
+       int v = 0;
+
+       while(*x__n++)
+               v++;
+
+       if (v < z - 1)
+       {
+               *--x__n = y;
+               *++x__n = 0;
+       }
+
+       return v;
+}
+
+bool charremove(char* mp, char remove)
+{
+       char* mptr = mp;
+       bool shift_down = false;
+
+       while (*mptr)
+       {
+               if (*mptr == remove)
+               shift_down = true;
+
+               if (shift_down)
+                       *mptr = *(mptr+1);
+
+               mptr++;
+       }
+
+       return shift_down;
+}
+
index 7747664ac387ebf06f01367279fc8d56e959d127..266d06350b48b905fde9dc2696ef63ee313e68d1 100644 (file)
@@ -168,7 +168,7 @@ userrec* ModeParser::SanityChecks(userrec *user,const char *dest,chanrec *chan,i
        {
                return NULL;
        }
-       d = Find(dest);
+       d = ServerInstance->FindNick(dest);
        if (!d)
        {
                user->WriteServ("401 %s %s :No such nick/channel",user->nick, dest);
@@ -250,7 +250,7 @@ void ModeParser::DisplayCurrentModes(userrec *user, userrec* targetuser, chanrec
        if (targetchannel)
        {
                /* Display channel's current mode string */
-               user->WriteServ("324 %s %s +%s",user->nick, targetchannel->name, chanmodes(targetchannel, targetchannel->HasUser(user)));
+               user->WriteServ("324 %s %s +%s",user->nick, targetchannel->name, targetchannel->ChanModes(targetchannel->HasUser(user)));
                user->WriteServ("329 %s %s %d", user->nick, targetchannel->name, targetchannel->created);
                return;
        }
@@ -272,8 +272,8 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
        std::string target = parameters[0];
        ModeType type = MODETYPE_USER;
        unsigned char mask = 0;
-       chanrec* targetchannel = FindChan(parameters[0]);
-       userrec* targetuser  = Find(parameters[0]);
+       chanrec* targetchannel = ServerInstance->FindChan(parameters[0]);
+       userrec* targetuser  = ServerInstance->FindNick(parameters[0]);
 
        log(DEBUG,"ModeParser::Process start");
 
index 47913bdc035ef1b6a7a8feaa3e2ed3fa32add2dd..d0c783ad9a5ae10ccc732d4ba5709ccc4b33125f 100644 (file)
@@ -71,7 +71,7 @@ std::string& ModeChannelBan::AddBan(userrec *user,std::string &dest,chanrec *cha
        if (dest == "")
                return dest;
 
-       long maxbans = GetMaxBans(chan->name);
+       long maxbans = chan->GetMaxBans();
        if ((unsigned)chan->bans.size() > (unsigned)maxbans)
        {
                user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %d)",user->nick, chan->name,chan->name,maxbans);
index 5137bfd4a4876e7cdf64caa159eaf4a82962073b..49bf082880d30e9aec2477f5af75f56e639f5e8d 100644 (file)
@@ -16,7 +16,7 @@
 #include "modes/cmode_h.h"
 
 extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
+
 extern std::vector<Module*> modules;
 extern std::vector<ircd_module*> factory;
 extern int MODCOUNT;
@@ -28,17 +28,17 @@ ModeChannelHalfOp::ModeChannelHalfOp() : ModeHandler('h', 1, 1, true, MODETYPE_C
 
 ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
 {
-       userrec* x = Find(parameter);
+       userrec* x = ServerInstance->FindNick(parameter);
        if (x)
        {
-               if (cstatus(x, channel) == STATUS_HOP)
-               {
-                       return std::make_pair(true, x->nick);
-               }
-               else
-               {
-                       return std::make_pair(false, parameter);
-               }
+               if (cstatus(x, channel) == STATUS_HOP)
+               {
+                       return std::make_pair(true, x->nick);
+               }
+               else
+               {
+                       return std::make_pair(false, parameter);
+               }
        }
        return std::make_pair(false, parameter);
 }
index e8c3cbed7e0f7b1be121ce7a1eeacbcb29194a2f..580fcc636ede72ca089541037b7225c9c796ae5b 100644 (file)
@@ -16,7 +16,7 @@
 #include "modes/cmode_o.h"
 
 extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
+
 extern std::vector<Module*> modules;
 extern std::vector<ircd_module*> factory;
 extern int MODCOUNT;
@@ -28,18 +28,18 @@ ModeChannelOp::ModeChannelOp() : ModeHandler('o', 1, 1, true, MODETYPE_CHANNEL,
 
 ModePair ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
 {
-        userrec* x = Find(parameter);
-        if (x)
-        {
-                if (cstatus(x, channel) == STATUS_OP)
-                {
-                        return std::make_pair(true, x->nick);
-                }
-                else
-                {
-                        return std::make_pair(false, parameter);
-                }
-        }
+       userrec* x = ServerInstance->FindNick(parameter);
+       if (x)
+       {
+               if (cstatus(x, channel) == STATUS_OP)
+               {
+                       return std::make_pair(true, x->nick);
+               }
+               else
+               {
+                       return std::make_pair(false, parameter);
+               }
+       }
        return std::make_pair(false, parameter);
 }
 
index ddac844ec226740afcf0705df826b11f7941887a..b93a04f4981d3d2c2d2335800d42fae521a57ccb 100644 (file)
@@ -16,7 +16,7 @@
 #include "modes/cmode_v.h"
 
 extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
+
 extern std::vector<Module*> modules;
 extern std::vector<ircd_module*> factory;
 extern int MODCOUNT;
@@ -28,18 +28,18 @@ ModeChannelVoice::ModeChannelVoice() : ModeHandler('v', 1, 1, true, MODETYPE_CHA
 
 ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
 {
-        userrec* x = Find(parameter);
-        if (x)
-        {
-                if (cstatus(x, channel) == STATUS_VOICE)
-                {
-                        return std::make_pair(true, x->nick);
-                }
-                else
-                {
-                        return std::make_pair(false, parameter);
-                }
-        }
+       userrec* x = ServerInstance->FindNick(parameter);
+       if (x)
+       {
+               if (cstatus(x, channel) == STATUS_VOICE)
+               {
+                       return std::make_pair(true, x->nick);
+               }
+               else
+               {
+                       return std::make_pair(false, parameter);
+               }
+       }
        return std::make_pair(false, parameter);
 }
 
index 1566ac5d752f7f2d5a04f0d5debf15160a190e56..da4a7e152b8354286342ca5213f16f86ed8ec663 100644 (file)
@@ -326,7 +326,7 @@ const std::string& Server::GetModuleName(Module* m)
 
 void Server::RehashServer()
 {
-       WriteOpers("*** Rehashing config file");
+       ServerInstance->WriteOpers("*** Rehashing config file");
        ServerInstance->Config->Read(false,NULL);
 }
 
@@ -375,11 +375,6 @@ chanrec* Server::GetChannelIndex(long index)
        return NULL;
 }
 
-void Server::SendOpers(const std::string &s)
-{
-       WriteOpers("%s",s.c_str());
-}
-
 bool Server::MatchText(const std::string &sliteral, const std::string &spattern)
 {
        return match(sliteral.c_str(),spattern.c_str());
@@ -440,21 +435,11 @@ bool Server::IsNick(const std::string &nick)
        return (isnick(nick.c_str()) != 0);
 }
 
-userrec* Server::FindNick(const std::string &nick)
-{
-       return Find(nick);
-}
-
 userrec* Server::FindDescriptor(int socket)
 {
        return (socket < 65536 ? ServerInstance->fd_ref_table[socket] : NULL);
 }
 
-chanrec* Server::FindChannel(const std::string &channel)
-{
-       return FindChan(channel.c_str());
-}
-
 std::string Server::ChanMode(userrec* User, chanrec* Chan)
 {
        return cmode(User,Chan);
@@ -553,7 +538,7 @@ bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &
                                        zombie->WriteServ("332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
                                        zombie->WriteServ("333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
                                }
-                               userlist(zombie,Ptr);
+                               Ptr->UserList(zombie);
                                zombie->WriteServ("366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
                }
        }
@@ -786,11 +771,11 @@ void ConfigReader::DumpErrors(bool bail, userrec* user)
                }
                else
                {
-                       WriteOpers("There were errors in the configuration file:");
+                       ServerInstance->WriteOpers("There were errors in the configuration file:");
                        
                        while(start < errors.length())
                        {
-                               WriteOpers(errors.substr(start, 360).c_str());
+                               ServerInstance->WriteOpers(errors.substr(start, 360).c_str());
                                start += 360;
                        }
                }
index 93d763cb582710e47ada0bc34d8542c4f258b659..bc72e0e0c89aafdb7e8da53fee2d8c811fe4b76f 100644 (file)
@@ -130,7 +130,7 @@ public:
                                log(DEBUG, "SQLrequest failed: %s", req.error.Str());
                        
                                if (verbose)
-                                       WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
+                                       ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
                        
                                return false;
                        }
@@ -170,14 +170,14 @@ public:
                                        else if (verbose)
                                        {
                                                /* No rows in result, this means there was no record matching the user */
-                                               WriteOpers("Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick, user->ident, user->host);
+                                               ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick, user->ident, user->host);
                                                user->Extend("sqlauth_failed");
                                        }
                                }
                                else if (verbose)
                                {
                                        log(DEBUG, "Query failed: %s", res->error.Str());
-                                       WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, res->error.Str());
+                                       ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, res->error.Str());
                                        user->Extend("sqlauth_failed");
                                }
                        }
index 2ec6085fc9057de4be1ba8229cb9570f86305ece..9d48b1034c7197118201e771b17d574b16ddd345 100644 (file)
@@ -25,6 +25,8 @@ using namespace std;
 
 /* $ModDesc: Provides aliases of commands. */
 
+extern InspIRCd* ServerInstance;
+
 class Alias : public classbase
 {
        public:
@@ -106,7 +108,7 @@ class ModuleAlias : public Module
                                {
                                        if (Aliases[i].requires != "")
                                        {
-                                               u = Srv->FindNick(Aliases[i].requires);
+                                               u = ServerInstance->FindNick(Aliases[i].requires);
                                                if (!u)
                                                {
                                                        user->WriteServ("401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is currently unavailable. Please try again later.");
@@ -117,7 +119,7 @@ class ModuleAlias : public Module
                                        {
                                                if (!Srv->IsUlined(u->server))
                                                {
-                                                       Srv->SendOpers("*** NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!"); 
+                                                       ServerInstance->WriteOpers("*** NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!"); 
                                                        user->WriteServ("401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is an imposter! Please inform an IRC operator as soon as possible.");
                                                        return 1;
                                                }
index 9567f2de704bd86a70056e165ecab628dac563bb..b22b5b327063a9cdd22f4f715075e76e003e3ce2 100644 (file)
@@ -140,7 +140,7 @@ public:
                        {
                                // Block it...
                                if(action == IBLOCK_KILLOPERS || action == IBLOCK_NOTICEOPERS)
-                                       WriteOpers("*** %s had an /amsg or /ame denied", user->nick);
+                                       ServerInstance->WriteOpers("*** %s had an /amsg or /ame denied", user->nick);
 
                                if(action == IBLOCK_KILL || action == IBLOCK_KILLOPERS)
                                        userrec::QuitUser(ServerInstance, user, "Global message (/amsg or /ame) detected");
index eb971864b847de5998650468d12b31422489862c..e4fa5d91bf43575df962e6a8cfe33e8eb373053f 100644 (file)
@@ -28,6 +28,8 @@
 
 /* $ModDesc: Gives /cban, aka C:lines. Think Q:lines, for channels. */
 
+extern InspIRCd* ServerInstance;
+
 class CBan : public classbase
 {
 public:
@@ -109,12 +111,12 @@ class cmd_cban : public command_t
                                if(length > 0)
                                {
                                        user->WriteServ( "385 %s %s :Added %lu second channel ban (%s)", user->nick, parameters[0], length, reason.c_str());
-                                       WriteOpers("*** %s added %lu second channel ban on %s (%s)", user->nick, length, parameters[0], reason.c_str());
+                                       ServerInstance->WriteOpers("*** %s added %lu second channel ban on %s (%s)", user->nick, length, parameters[0], reason.c_str());
                                }
                                else
                                {
                                        user->WriteServ( "385 %s %s :Added permenant channel ban (%s)", user->nick, parameters[0], reason.c_str());
-                                       WriteOpers("*** %s added permenant channel ban on %s (%s)", user->nick, parameters[0], reason.c_str());
+                                       ServerInstance->WriteOpers("*** %s added permenant channel ban on %s (%s)", user->nick, parameters[0], reason.c_str());
                                }
                        }
                        else
@@ -170,7 +172,7 @@ class ModuleCBan : public Module
                        {
                                // Channel is banned.
                                user->WriteServ( "384 %s %s :Cannot join channel, CBANed (%s)", user->nick, cname, iter->reason.c_str());
-                               WriteOpers("*** %s tried to join %s which is CBANed (%s)", user->nick, cname, iter->reason.c_str());
+                               ServerInstance->WriteOpers("*** %s tried to join %s which is CBANed (%s)", user->nick, cname, iter->reason.c_str());
                                return 1;
                        }
                }
@@ -245,7 +247,7 @@ void ExpireBans()
                                if (iter->set_on + iter->length <= TIME)
                                {
                                        log(DEBUG, "m_cban.so: Ban on %s expired, removing...", iter->chname.c_str());
-                                       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(), TIME - iter->set_on);
                                        cbans.erase(iter);
                                        go_again = true;
                                }
index 31b5dc09204676db16ce46401fea8370253c564d..7bb46b753b8b8393df70b00fdee75a7d27464263 100644 (file)
@@ -63,7 +63,7 @@ class CGIResolver : public Resolver
                if ((them) && (them == ServerInstance->fd_ref_table[theirfd]))
                {
                        if (notify)
-                               WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick, them->host, result.c_str(), typ.c_str());
+                               ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick, them->host, result.c_str(), typ.c_str());
 
                        strlcpy(them->host, result.c_str(), 63);
                        strlcpy(them->dhost, result.c_str(), 63);
@@ -76,7 +76,7 @@ class CGIResolver : public Resolver
                if ((them) && (them == ServerInstance->fd_ref_table[theirfd]))
                {
                        if (notify)
-                               WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved from their %s!", them->nick, them->host,typ.c_str());
+                               ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved from their %s!", them->nick, them->host,typ.c_str());
                }
        }
 
@@ -253,7 +253,7 @@ public:
                                log(DEBUG, "m_cgiirc.so: Got an IP in the user's password");
 
                                if(NotifyOpers)
-                                       WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from PASS", user->nick, user->host, user->password);
+                                       ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from PASS", user->nick, user->host, user->password);
                        }
                        else
                        {
@@ -268,14 +268,14 @@ public:
                                catch (ModuleException& e)
                                {
                                        if (NotifyOpers)
-                                               WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but i could not resolve their hostname!", user->nick, user->host);
+                                               ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but i could not resolve their hostname!", user->nick, user->host);
                                }
                        }
                        
                        *user->password = 0;
 
                        /*if(NotifyOpers)
-                               WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from PASS", user->nick, user->host, user->password);*/
+                               ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from PASS", user->nick, user->host, user->password);*/
 
                        return true;
                }
@@ -328,7 +328,7 @@ public:
                        strlcpy(user->ident, "~cgiirc", 8);
 
                        if(NotifyOpers)
-                                WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but i could not resolve their hostname!", user->nick, user->host);
+                                ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but i could not resolve their hostname!", user->nick, user->host);
                }
                /*strlcpy(user->host, newip, 16);
                strlcpy(user->dhost, newip, 16);
index 53e725504ad10ff3920a2a72e1f463f8d753b0c6..41b78f98bfae7db352c43b953c77c9878ae55478 100644 (file)
@@ -22,6 +22,8 @@
 
 /* $ModDesc: Provides channel modes +a and +q */
 
+extern InspIRCd* ServerInstance;
+
 const char* fakevalue = "on";
 
 class ChanFounder : public ModeHandler
@@ -34,7 +36,7 @@ class ChanFounder : public ModeHandler
 
        ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
        {
-               userrec* x = Find(parameter);
+               userrec* x = ServerInstance->FindNick(parameter);
                if (x)
                {
                        if (!channel->HasUser(x))
@@ -60,7 +62,7 @@ class ChanFounder : public ModeHandler
 
        ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
        {
-               userrec* theuser = Srv->FindNick(parameter);
+               userrec* theuser = ServerInstance->FindNick(parameter);
 
                log(DEBUG,"ChanFounder::OnModeChange");
 
@@ -149,7 +151,7 @@ class ChanProtect : public ModeHandler
 
        ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
        {
-               userrec* x = Find(parameter);
+               userrec* x = ServerInstance->FindNick(parameter);
                if (x)
                {
                        if (!channel->HasUser(x))
@@ -174,7 +176,7 @@ class ChanProtect : public ModeHandler
 
        ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
        {
-               userrec* theuser = Srv->FindNick(parameter);
+               userrec* theuser = ServerInstance->FindNick(parameter);
 
                // cant find the user given as the parameter, eat the mode change.
                if (!theuser)
index 7dcb86d38a61eb43f775fdc34663561c51f30e56..f8d84154efbff09ae0b94ee766ebd6a35ccbcb9c 100644 (file)
@@ -53,8 +53,8 @@ class cmd_check : public command_t
 
                checkstr = "304 " + std::string(user->nick) + " :CHECK";
 
-               targuser = Srv->FindNick(std::string(parameters[0]));
-               targchan = Srv->FindChannel(std::string(parameters[0]));
+               targuser = ServerInstance->FindNick(parameters[0]);
+               targchan = ServerInstance->FindChan(parameters[0]);
 
                /*
                 * Syntax of a /check reply:
@@ -114,7 +114,7 @@ class cmd_check : public command_t
                                user->WriteServ(checkstr + " topic_setat " + timebuf);
                        }
 
-                       user->WriteServ(checkstr + " modes " + chanmodes(targchan, true));
+                       user->WriteServ(checkstr + " modes " + targchan->ChanModes(true));
                        user->WriteServ(checkstr + " membercount " + ConvToStr(targchan->GetUserCounter()));
                        
                        /* now the ugly bit, spool current members of a channel. :| */
index 23a482a65343427b51b5ec07c9542b0dd83a0eb9..fc5507822eb927bf7298ff01c0f921b93bc860a9 100644 (file)
@@ -22,10 +22,12 @@ using namespace std;
 #include "channels.h"
 #include "modules.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides support for the CHGHOST command */
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
 
 class cmd_chghost : public command_t
 {
@@ -56,13 +58,13 @@ class cmd_chghost : public command_t
                        user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick);
                        return;
                }
-               userrec* dest = Srv->FindNick(std::string(parameters[0]));
+               userrec* dest = ServerInstance->FindNick(parameters[0]);
                if (dest)
                {
                        if ((dest->ChangeDisplayedHost(parameters[1])) && (!Srv->IsUlined(user->server)))
                        {
                                // fix by brain - ulines set hosts silently
-                               Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
+                               ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+parameters[1]);
                        }
                }
        }
index 7cb09127a6d2a6e6a522ffeb110eec54af36aec9..391f4b20bcc25447da135f493d66f98e38d20ec6 100644 (file)
@@ -3,9 +3,12 @@
 #include "modules.h"
 #include "message.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides support for the CHGIDENT command */
 
+extern InspIRCd* ServerInstance;
+
 class cmd_chgident : public command_t
 {
        Server* Srv;
@@ -19,8 +22,8 @@ class cmd_chgident : public command_t
        
        void Handle(const char** parameters, int pcnt, userrec *user)
        {
-               userrec* dest = Srv->FindNick(std::string(parameters[0]));
-               
+               userrec* dest = ServerInstance->FindNick(parameters[0]);
+
                if(dest)
                {
                        if(!isident(parameters[1]))
@@ -29,7 +32,7 @@ class cmd_chgident : public command_t
                                return;
                        }
                
-                       WriteOpers("%s used CHGIDENT to change %s's ident from '%s' to '%s'", user->nick, dest->nick, dest->ident, parameters[1]);
+                       ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident from '%s' to '%s'", user->nick, dest->nick, dest->ident, parameters[1]);
                        strlcpy(dest->ident, parameters[1], IDENTMAX+2);
                }
                else
index b1a9d8c7ce7e4e0ab7f94c78e6e934ef4fd1d33f..85ea0a84d0a9e60ff9847343304dad162c0b74a1 100644 (file)
@@ -95,7 +95,7 @@ public:
                        {
                                /* expire throttle */
                                throttled = 0;
-                               Srv->SendOpers("*** Connection throttle deactivated");
+                               ServerInstance->WriteOpers("*** Connection throttle deactivated");
                                return;
                        }
                        userrec::QuitUser(ServerInstance, user, quitmsg);
@@ -107,7 +107,7 @@ public:
                        if (conns >= maxconns)
                        {
                                throttled = 1;
-                               Srv->SendOpers("*** Connection throttle activated");
+                               ServerInstance->WriteOpers("*** Connection throttle activated");
                                userrec::QuitUser(ServerInstance, user, quitmsg);
                                return;
                        }
index 0f94779217aea76e55fb252d514de43dc8a6a477..13e68f943157f6e700414f12f69c3afd88afec31 100644 (file)
@@ -107,11 +107,8 @@ class ModuleFilter : public Module
 
                                if (f->action == "block")
                                {       
-                                       Srv->SendOpers(std::string("FILTER: ")+std::string(user->nick)+
-                                                       std::string(" had their notice filtered, target was ")+
-                                                       target+": "+f->reason);
-                                       user->WriteServ("NOTICE "+std::string(user->nick)+
-                                                       " :Your notice has been filtered and opers notified: "+f->reason);
+                                       ServerInstance->WriteOpers(std::string("FILTER: ")+user->nick+" had their notice filtered, target was "+target+": "+f->reason);
+                                       user->WriteServ("NOTICE "+std::string(user->nick)+" :Your notice has been filtered and opers notified: "+f->reason);
                                }
                                Srv->Log(DEFAULT,std::string("FILTER: ")+std::string(user->nick)+
                                                std::string(" had their notice filtered, target was ")+
index ca5bdda7e3ee1622de9694753ea59a0fb6da0fb6..8e68d48a676aec80fe4f5b1b0dcf2c2f3974653e 100644 (file)
@@ -40,7 +40,7 @@ class cmd_gloadmodule : public command_t
        {
                if (ServerInstance->LoadModule(parameters[0]))
                {
-                       WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
+                       ServerInstance->WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
                        user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
                }
                else
@@ -63,7 +63,7 @@ class cmd_gunloadmodule : public command_t
        {
                if (ServerInstance->UnloadModule(parameters[0]))
                {
-                       WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
+                       ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
                        user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
                }
                else
index fa4f27f0457146f7364de632678ac0bcc52cea6e..a8f66b6a771a592964d42de74da8a00d42d86095 100644 (file)
@@ -145,7 +145,7 @@ class ModuleHttpStats : public Module
                                int n = 0;
                                for (SortedIter a = so->begin(); ((a != so->end()) && (n < 25)); a++, n++)
                                {
-                                       chanrec* c = Srv->FindChannel(a->second.c_str());
+                                       chanrec* c = ServerInstance->FindChan(a->second.c_str());
                                        if (c)
                                        {
                                                data << "<tr><td>" << a->first << "</td><td>" << a->second << "</td>";
index 8f040cd3873951c7c7570caea50aa55cd8bb6e84..e681f02d674984a1b4a2ccb02c7b55e1dbe3cc17 100644 (file)
@@ -27,6 +27,7 @@ using namespace std;
 /* $ModDesc: Provides support for /KNOCK and mode +K */
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
 
 class cmd_knock : public command_t
 {
@@ -39,7 +40,7 @@ class cmd_knock : public command_t
        
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               chanrec* c = Srv->FindChannel(parameters[0]);
+               chanrec* c = ServerInstance->FindChan(parameters[0]);
 
                if (!c)
                {
index e46b56901fe1c63907ef67c575c4a87628dcdf3e..58a4c2686ec146ba91120d823b40c605d139011e 100644 (file)
@@ -23,6 +23,7 @@ using namespace std;
 #include "modules.h"
 #include "helperfuncs.h"
 #include "hashcomp.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides the NICKLOCK command, allows an oper to chage a users nick and lock them to it until they quit */
 
@@ -41,7 +42,7 @@ class cmd_nicklock : public command_t
 
        void Handle(const char** parameters, int pcnt, userrec *user)
        {
-               userrec* source = Srv->FindNick(std::string(parameters[0]));
+               userrec* source = ServerInstance->FindNick(parameters[0]);
                irc::string server;
                irc::string me;
 
@@ -55,7 +56,7 @@ class cmd_nicklock : public command_t
                        if (Srv->IsNick(std::string(parameters[1])))
                        {
                                // give them a lock flag
-                               Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
+                               ServerInstance->WriteOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+parameters[0]+" to "+parameters[1]);
                                if (!source->ForceNickChange(parameters[1]))
                                {
                                        userrec::QuitUser(ServerInstance, source, "Nickname collision");
@@ -78,12 +79,12 @@ class cmd_nickunlock : public command_t
 
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               userrec* source = Srv->FindNick(std::string(parameters[0]));
+               userrec* source = ServerInstance->FindNick(parameters[0]);
                if (source)
                {
                        source->Shrink("nick_locked");
                        user->WriteServ("945 %s %s :Nickname now unlocked.",user->nick,source->nick);
-                       Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
+                       ServerInstance->WriteOpers(std::string(user->nick)+" used NICKUNLOCK on "+parameters[0]);
                }
        }
 };
index cc248718fda06bfcac0f501f7b2b1f45457245c7..0c97765b9e5e1982d85ff5d91e0e09fee86f7e36 100644 (file)
@@ -9,6 +9,8 @@ using namespace std;
 
 /* $ModDesc: Gives each oper type a 'level', cannot kill opers 'above' your level. */
 
+extern InspIRCd* ServerInstance;
+
 class ModuleOperLevels : public Module
 {
 
@@ -74,7 +76,7 @@ class ModuleOperLevels : public Module
                                }
                                if (dest_level > source_level)
                                {
-                                       WriteOpers("Oper %s (level %d) attempted to /kill a higher oper: %s (level %d): Reason: %s",source->nick,source_level,dest->nick,dest_level,reason.c_str());
+                                       ServerInstance->WriteOpers("Oper %s (level %d) attempted to /kill a higher oper: %s (level %d): Reason: %s",source->nick,source_level,dest->nick,dest_level,reason.c_str());
                                        dest->WriteServ("NOTICE %s :Oper %s attempted to /kill you!",dest->nick,source->nick);
                                        source->WriteServ("481 %s :Permission Denied- Oper %s is a higher level than you",source->nick,dest->nick);
                                        return 1;
index c16a2125fb7e979b48dd2881357bfafb28dd5159..4f188b0cbcb409bf805b4dd93ce68a165fdffa31 100644 (file)
@@ -22,6 +22,8 @@
 
 /* $ModDesc: Provides support for unreal-style oper-override */
 
+extern InspIRCd* ServerInstance;
+
 typedef std::map<std::string,std::string> override_t;
 
 class ModuleOverride : public Module
@@ -93,7 +95,7 @@ class ModuleOverride : public Module
                {
                        if (((Srv->ChanMode(source,chan) == "%") && (Srv->ChanMode(user,chan) == "@")) || (Srv->ChanMode(source,chan) == ""))
                        {
-                               Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Kicked "+std::string(user->nick)+" on "+std::string(chan->name)+" ("+reason+")");
+                               ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Kicked "+std::string(user->nick)+" on "+std::string(chan->name)+" ("+reason+")");
                        }
                        /* Returning -1 explicitly allows the kick */
                        return -1;
@@ -117,7 +119,7 @@ class ModuleOverride : public Module
                                                case AC_DEOP:
                                                        if (CanOverride(source,"MODEDEOP"))
                                                        {
-                                                               Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Deopped "+std::string(dest->nick)+" on "+std::string(channel->name));
+                                                               ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Deopped "+std::string(dest->nick)+" on "+std::string(channel->name));
                                                                return ACR_ALLOW;
                                                        }
                                                        else
@@ -128,7 +130,7 @@ class ModuleOverride : public Module
                                                case AC_OP:
                                                        if (CanOverride(source,"MODEOP"))
                                                        {
-                                                               Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Opped "+std::string(dest->nick)+" on "+std::string(channel->name));
+                                                               ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Opped "+std::string(dest->nick)+" on "+std::string(channel->name));
                                                                return ACR_ALLOW;
                                                        }
                                                        else
@@ -139,7 +141,7 @@ class ModuleOverride : public Module
                                                case AC_VOICE:
                                                        if (CanOverride(source,"MODEVOICE"))
                                                        {
-                                                               Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Voiced "+std::string(dest->nick)+" on "+std::string(channel->name));
+                                                               ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Voiced "+std::string(dest->nick)+" on "+std::string(channel->name));
                                                                return ACR_ALLOW;
                                                        }
                                                        else
@@ -150,7 +152,7 @@ class ModuleOverride : public Module
                                                case AC_DEVOICE:
                                                        if (CanOverride(source,"MODEDEVOICE"))
                                                        {
-                                                               Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Devoiced "+std::string(dest->nick)+" on "+std::string(channel->name));
+                                                               ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Devoiced "+std::string(dest->nick)+" on "+std::string(channel->name));
                                                                return ACR_ALLOW;
                                                        }
                                                        else
@@ -161,7 +163,7 @@ class ModuleOverride : public Module
                                                case AC_HALFOP:
                                                        if (CanOverride(source,"MODEHALFOP"))
                                                        {
-                                                               Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Halfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
+                                                               ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Halfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
                                                                return ACR_ALLOW;
                                                        }
                                                        else
@@ -172,7 +174,7 @@ class ModuleOverride : public Module
                                                case AC_DEHALFOP:
                                                        if (CanOverride(source,"MODEDEHALFOP"))
                                                        {
-                                                               Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Dehalfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
+                                                               ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Dehalfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
                                                                return ACR_ALLOW;
                                                        }
                                                        else
@@ -213,7 +215,7 @@ class ModuleOverride : public Module
                                                        chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s invited himself into the channel", cname, user->nick);
                                                }
                                        }
-                                       Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname));
+                                       ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname));
                                        return -1;
                                }
                                
@@ -221,7 +223,7 @@ class ModuleOverride : public Module
                                {
                                        if (NoisyOverride)
                                                chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s bypassed the channel key", cname, user->nick);
-                                       Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +k on "+std::string(cname));
+                                       ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used operoverride to bypass +k on "+std::string(cname));
                                        return -1;
                                }
                                        
@@ -229,7 +231,7 @@ class ModuleOverride : public Module
                                {
                                        if (NoisyOverride)
                                                chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s passed through your channel limit", cname, user->nick);
-                                       Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +l on "+std::string(cname));
+                                       ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used operoverride to bypass +l on "+std::string(cname));
                                        return -1;
                                }
 
index 8502fbfdb74cc76dec29cd48b9761c711d8afb68..3629e9b48cf84340d164f86ef14edc5875c2d09e 100644 (file)
@@ -146,7 +146,7 @@ class cmd_unpark : public command_t
                 *
                 * And there you have it, easy huh (NOT)...
                 */
-               userrec* unpark = Srv->FindNick(std::string(parameters[0]));
+               userrec* unpark = ServerInstance->FindNick(parameters[0]);
                if (!unpark)
                {
                        user->WriteServ("942 %s %s :Invalid user specified.",user->nick, parameters[0]);
@@ -322,7 +322,7 @@ class ModulePark : public Module
                        {
                                if (time(NULL) >= (j->parktime+ParkMaxTime))
                                {
-                                       userrec* thisnick = Srv->FindNick(j->nick);
+                                       userrec* thisnick = ServerInstance->FindNick(j->nick);
                                        // THIS MUST COME BEFORE THE QuitUser - QuitUser can
                                        // create a recursive call to OnUserQuit in this module
                                        // and then corrupt the pointer!
index 4d8d717abbe236ce52715e88d77758be53d1a8bb..c143cab524d31872752349c7ad9f9dba4483adc1 100644 (file)
@@ -60,7 +60,7 @@ class Redirect : public ModeHandler
                                return MODEACTION_DENY;
                        }
 
-                       c = Srv->FindChannel(parameter);
+                       c = ServerInstance->FindChan(parameter);
                        if (c)
                        {
                                /* Fix by brain: Dont let a channel be linked to *itself* either */
index a5657f604d3ec178f9e29cf0a65f7ded3795e551..587edac864cd7b3e852ebc0655b62515462d83d7 100644 (file)
@@ -17,6 +17,8 @@
  * eg: +h can remove +hv and users with no modes. +a can remove +aohv and users with no modes.
 */
 
+extern InspIRCd* ServerInstance;
+
 class RemoveBase
 {
  private: 
@@ -85,10 +87,10 @@ class RemoveBase
                username = parameters[ neworder ? 1 : 0];
                
                /* Look up the user we're meant to be removing from the channel */
-               target = Srv->FindNick(username);
+               target = ServerInstance->FindNick(username);
                
                /* And the channel we're meant to be removing them from */
-               channel = Srv->FindChannel(channame);
+               channel = ServerInstance->FindChan(channame);
 
                /* Fix by brain - someone needs to learn to validate their input! */
                if (!target || !channel)
index 000d1e7d64dd5aa89492304d1e06ff4c540d9c1f..2aa5a02f6fb44ce7e81a0c19f7fc67fe9d9758b5 100644 (file)
@@ -107,7 +107,7 @@ class ListTimer : public InspTimer
                                                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);
+                                                       int counter = snprintf(buffer,MAXBUF,"322 %s %s %ld :[+%s] %s",u->nick,chan->name,users,chan->ChanModes(has_user),chan->topic);
                                                        /* Increment total plus linefeed */
                                                        amount_sent += counter + 4 + Srv->GetServerName().length();
                                                        log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax);
index af03f47d71ce6aaf46f37fc81a18052d3eda3b9f..65babdfa4c19e16c8acbf30de4258ca416ccf581 100644 (file)
@@ -40,7 +40,7 @@ class cmd_sajoin : public command_t
 
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               userrec* dest = Srv->FindNick(std::string(parameters[0]));
+               userrec* dest = ServerInstance->FindNick(parameters[0]);
                if (dest)
                {
                        if (Srv->IsUlined(dest->server))
@@ -55,7 +55,7 @@ class cmd_sajoin : public command_t
                                return;
                        }
 
-                       Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
+                       ServerInstance->WriteOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
                        chanrec::JoinUser(ServerInstance, dest, parameters[1], true);
                }
        }
index 012bfed89a0429a7846b7d3fd782f9d55f71398a..104e5da337deb198e9a2666bcd240174dc47dfed 100644 (file)
@@ -68,7 +68,7 @@ class cmd_samode : public command_t
                        result.append(" ");
                        result.append(parameters[n]);
                }
-               Srv->SendOpers(result);
+               ServerInstance->WriteOpers(result);
        }
 };
 
index db35b9ba561f9255ecbe6858d6d55eec47ee17dd..a323844d55937793a157f0a99e7be733f44a3d80 100644 (file)
@@ -39,7 +39,7 @@ class cmd_sanick : public command_t
 
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               userrec* source = Srv->FindNick(std::string(parameters[0]));
+               userrec* source = ServerInstance->FindNick(parameters[0]);
                if (source)
                {
                        if (Srv->IsUlined(source->server))
@@ -51,7 +51,7 @@ class cmd_sanick : public command_t
                        {
                                // FIX by brain: Cant use source->nick here because if it traverses a server link then
                                // source->nick becomes invalid as the object data moves in memory.
-                               Srv->SendOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]);
+                               ServerInstance->WriteOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]);
                                if (!source->ForceNickChange(parameters[1]))
                                {
                                        /* We couldnt change the nick */
index 4493a178f9c2491f5674bfa00bdb29a3100e9eda..fb4117b421814e4a4ece31ca3ac5db2587181875 100644 (file)
@@ -27,6 +27,7 @@ using namespace std;
 /* $ModDesc: Provides support for unreal-style SAPART command */
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
 
 class cmd_sapart : public command_t
 {
@@ -39,8 +40,8 @@ class cmd_sapart : public command_t
         
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               userrec* dest = Srv->FindNick(parameters[0]);
-               chanrec* channel = Srv->FindChannel(parameters[1]);
+               userrec* dest = ServerInstance->FindNick(parameters[0]);
+               chanrec* channel = ServerInstance->FindChan(parameters[1]);
                if (dest && channel)
                {
                        if (Srv->IsUlined(dest->server))
@@ -48,7 +49,7 @@ class cmd_sapart : public command_t
                                user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
                                return;
                        }
-                       Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
+                       ServerInstance->WriteOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
                        if (!channel->PartUser(dest, dest->nick))
                                delete channel;
                }
index dd02d4e418738c919f78d9f9a045b442194fc48a..4900a3db80af9e7dfc16aa05b32181990260a283 100644 (file)
@@ -49,7 +49,7 @@ class cmd_saquit : public command_t
 
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               userrec* dest = Srv->FindNick(std::string(parameters[0]));
+               userrec* dest = ServerInstance->FindNick(parameters[0]);
                if (dest)
                {
                        if (Srv->IsUlined(dest->server))
@@ -64,7 +64,7 @@ class cmd_saquit : public command_t
                        }
                        line = line + std::string(parameters[pcnt-1]);
                
-                       Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
+                       ServerInstance->WriteOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
                        userrec::QuitUser(ServerInstance, dest, line);
                }
        }
index 631bd13a1fc1c64ac22987809d71134f73fa2c5e..697ba1dfde524678f39e0b857d103a13560e1c91 100644 (file)
@@ -22,10 +22,12 @@ using namespace std;
 #include "channels.h"
 #include "modules.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides support for the SETHOST command */
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
 
 class cmd_sethost : public command_t
 {
@@ -55,7 +57,7 @@ class cmd_sethost : public command_t
                        }
                }
                if (user->ChangeDisplayedHost(parameters[0]))
-                       Srv->SendOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[0]));
+                       ServerInstance->WriteOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[0]));
        }
 };
 
index a5eb27a9b06cbfb5ca6a6242fb29e28b7c924b0d..b3bcef53ba598acba6ee758cbb08e2aa61cad6e3 100644 (file)
@@ -1,10 +1,12 @@
 #include "users.h"
 #include "modules.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides support for the SETIDENT command */
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
 
 class cmd_setident : public command_t
 {
@@ -26,7 +28,7 @@ class cmd_setident : public command_t
                        return;
                }
                
-               WriteOpers("%s used SETIDENT to change their ident from '%s' to '%s'", user->nick, user->ident, parameters[0]);
+               ServerInstance->WriteOpers("%s used SETIDENT to change their ident from '%s' to '%s'", user->nick, user->ident, parameters[0]);
                strlcpy(user->ident, parameters[0], IDENTMAX+2);
        }
 };
index f17f69e09e20139590e6cd4e7f828f657bddea5d..c83c7e7e021eaf2f06e46849033d061a773a405b 100644 (file)
@@ -22,10 +22,12 @@ using namespace std;
 #include "channels.h"
 #include "modules.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Allows opers to set their idle time */
 
 static Server *Srv = NULL;
+extern InspIRCd* ServerInstance;
 
 class cmd_setidle : public command_t
 {
@@ -47,7 +49,7 @@ class cmd_setidle : public command_t
                // minor tweak - we cant have signon time shorter than our idle time!
                if (user->signon > user->idle_lastmsg)
                        user->signon = user->idle_lastmsg;
-               Srv->SendOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds");
+               ServerInstance->WriteOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds");
                user->WriteServ("944 %s :Idle time set.",user->nick);
        }
 };
index 72ae322f643fc8af70b3a0f0fe927e2a63148eb8..21209ab6a45f4e85c13ad672de380d010b089a85 100644 (file)
@@ -617,7 +617,7 @@ class cmd_rconnect : public command_t
                if (Srv->MatchText(Srv->GetServerName(),parameters[0]))
                {
                        /* Yes, initiate the given connect */
-                       WriteOpers("*** Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0],parameters[1]);
+                       ServerInstance->WriteOpers("*** Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0],parameters[1]);
                        const char* para[1];
                        para[0] = parameters[1];
                        Creator->OnPreCommand("CONNECT", para, 1, user, true);
@@ -713,12 +713,12 @@ class TreeSocket : public InspSocket
                keylength = key.length();
                if (!(keylength == 16 || keylength == 24 || keylength == 32))
                {
-                       WriteOpers("*** \2ERROR\2: Key length for encryptionkey is not 16, 24 or 32 bytes in length!");
+                       ServerInstance->WriteOpers("*** \2ERROR\2: Key length for encryptionkey is not 16, 24 or 32 bytes in length!");
                        log(DEBUG,"Key length not 16, 24 or 32 characters!");
                }
                else
                {
-                       WriteOpers("*** \2AES\2: Initialized %d bit encryption to server %s",keylength*8,SName.c_str());
+                       ServerInstance->WriteOpers("*** \2AES\2: Initialized %d bit encryption to server %s",keylength*8,SName.c_str());
                        ctx_in->MakeKey(key.c_str(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
                                \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", keylength, keylength);
                        ctx_out->MakeKey(key.c_str(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
@@ -741,13 +741,13 @@ class TreeSocket : public InspSocket
                        {
                                if (x->Name == this->myhost)
                                {
-                                       Srv->SendOpers("*** Connection to \2"+myhost+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] established.");
+                                       ServerInstance->WriteOpers("*** Connection to \2"+myhost+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] established.");
                                        this->SendCapabilities();
                                        if (x->EncryptionKey != "")
                                        {
                                                if (!(x->EncryptionKey.length() == 16 || x->EncryptionKey.length() == 24 || x->EncryptionKey.length() == 32))
                                                {
-                                                       WriteOpers("\2WARNING\2: Your encryption key is NOT 16, 24 or 32 characters in length, encryption will \2NOT\2 be enabled.");
+                                                       ServerInstance->WriteOpers("\2WARNING\2: Your encryption key is NOT 16, 24 or 32 characters in length, encryption will \2NOT\2 be enabled.");
                                                }
                                                else
                                                {
@@ -766,7 +766,7 @@ class TreeSocket : public InspSocket
                 * If that happens the connection hangs here until it's closed. Unlikely
                 * and rather harmless.
                 */
-               Srv->SendOpers("*** Connection to \2"+myhost+"\2 lost link tag(!)");
+               ServerInstance->WriteOpers("*** Connection to \2"+myhost+"\2 lost link tag(!)");
                return true;
        }
        
@@ -778,7 +778,7 @@ class TreeSocket : public InspSocket
                 */
                if (e == I_ERR_CONNECT)
                {
-                       Srv->SendOpers("*** Connection failed: Connection refused");
+                       ServerInstance->WriteOpers("*** Connection failed: Connection refused");
                }
        }
 
@@ -857,10 +857,10 @@ class TreeSocket : public InspSocket
                                quitserver = this->InboundServerName;
                        }
 
-                       WriteOpers("*** \2ERROR\2: Server '%s' does not have the same set of modules loaded, cannot link!",quitserver.c_str());
-                       WriteOpers("*** Our networked module set is: '%s'",this->MyCapabilities().c_str());
-                       WriteOpers("*** Other server's networked module set is: '%s'",params[0].c_str());
-                       WriteOpers("*** These lists must match exactly on both servers. Please correct these errors, and try again.");
+                       ServerInstance->WriteOpers("*** \2ERROR\2: Server '%s' does not have the same set of modules loaded, cannot link!",quitserver.c_str());
+                       ServerInstance->WriteOpers("*** Our networked module set is: '%s'",this->MyCapabilities().c_str());
+                       ServerInstance->WriteOpers("*** Other server's networked module set is: '%s'",params[0].c_str());
+                       ServerInstance->WriteOpers("*** These lists must match exactly on both servers. Please correct these errors, and try again.");
                        this->WriteLine("ERROR :CAPAB mismatch; My capabilities: '"+this->MyCapabilities()+"'");
                        return false;
                }
@@ -904,11 +904,11 @@ class TreeSocket : public InspSocket
                        DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
                        if (Current->GetParent() == TreeRoot)
                        {
-                               Srv->SendOpers("Server \002"+Current->GetName()+"\002 split: "+reason);
+                               ServerInstance->WriteOpers("Server \002"+Current->GetName()+"\002 split: "+reason);
                        }
                        else
                        {
-                               Srv->SendOpers("Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
+                               ServerInstance->WriteOpers("Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
                        }
                        num_lost_servers = 0;
                        num_lost_users = 0;
@@ -917,7 +917,7 @@ class TreeSocket : public InspSocket
                        Current->Tidy();
                        Current->GetParent()->DelChild(Current);
                        DELETE(Current);
-                       WriteOpers("Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
+                       ServerInstance->WriteOpers("Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
                }
                else
                {
@@ -939,7 +939,7 @@ class TreeSocket : public InspSocket
                std::string sourceserv;
 
                /* Are we dealing with an FMODE from a user, or from a server? */
-               userrec* who = Srv->FindNick(source);
+               userrec* who = ServerInstance->FindNick(source);
                if (who)
                {
                        /* FMODE from a user, set sourceserv to the users server name */
@@ -975,7 +975,7 @@ class TreeSocket : public InspSocket
                                
                }
                 /* Extract the TS value of the object, either userrec or chanrec */
-               userrec* dst = Srv->FindNick(params[0]);
+               userrec* dst = ServerInstance->FindNick(params[0]);
                chanrec* chan = NULL;
                time_t ourTS = 0;
                if (dst)
@@ -984,7 +984,7 @@ class TreeSocket : public InspSocket
                }
                else
                {
-                       chan = Srv->FindChannel(params[0]);
+                       chan = ServerInstance->FindChan(params[0]);
                        if (chan)
                        {
                                ourTS = chan->age;
@@ -1291,7 +1291,7 @@ class TreeSocket : public InspSocket
                         */
                        if ((Srv->IsUlined(sourceserv)) && (TS > ourTS))
                        {
-                               WriteOpers("\2WARNING!\2 U-Lined server '%s' has bad TS for '%s' (accepted change): \2SYNC YOUR CLOCKS\2 to avoid this notice",sourceserv.c_str(),params[0].c_str());
+                               ServerInstance->WriteOpers("\2WARNING!\2 U-Lined server '%s' has bad TS for '%s' (accepted change): \2SYNC YOUR CLOCKS\2 to avoid this notice",sourceserv.c_str(),params[0].c_str());
                        }
                        /* Allow the mode, route it to either server or user command handling */
                        if (smode)
@@ -1317,7 +1317,7 @@ class TreeSocket : public InspSocket
                time_t ts = atoi(params[1].c_str());
                std::string nsource = source;
 
-               chanrec* c = Srv->FindChannel(params[0]);
+               chanrec* c = ServerInstance->FindChan(params[0]);
                if (c)
                {
                        if ((ts >= c->topicset) || (!*c->topic))
@@ -1332,7 +1332,7 @@ class TreeSocket : public InspSocket
                                 */
                                if (oldtopic != params[3])
                                {
-                                       userrec* user = Srv->FindNick(source);
+                                       userrec* user = ServerInstance->FindNick(source);
                                        if (!user)
                                        {
                                                c->WriteChannelWithServ(source.c_str(), "TOPIC %s :%s", c->name, c->topic);
@@ -1373,7 +1373,7 @@ class TreeSocket : public InspSocket
                time_t TS = atoi(params[1].c_str());
                char* key = "";
                
-               chanrec* chan = Srv->FindChannel(channel);
+               chanrec* chan = ServerInstance->FindChan(channel);
                if (chan)
                {
                        key = chan->key;
@@ -1384,7 +1384,7 @@ class TreeSocket : public InspSocket
                 * channel will let the other side apply their modes.
                 */
                time_t ourTS = time(NULL)+600;
-               chanrec* us = Srv->FindChannel(channel);
+               chanrec* us = ServerInstance->FindChan(channel);
                if (us)
                {
                        ourTS = us->age;
@@ -1424,7 +1424,7 @@ class TreeSocket : public InspSocket
                                                strlcat(modestring,"v",MAXBUF);
                                        break;
                                }
-                               who = Srv->FindNick(usr);
+                               who = ServerInstance->FindNick(usr);
                                if (who)
                                {
                                        chanrec::JoinUser(this->Instance, who, channel.c_str(), true, key);
@@ -1509,7 +1509,7 @@ class TreeSocket : public InspSocket
        {
                if (params.size() >= 2)
                {
-                       chanrec* c = Srv->FindChannel(params[0]);
+                       chanrec* c = ServerInstance->FindChan(params[0]);
                        if (c)
                        {
                                time_t theirTS = atoi(params[1].c_str());
@@ -1577,7 +1577,7 @@ class TreeSocket : public InspSocket
                else
                        _new->SetSockAddr(AF_INET, params[6].c_str(), 0);
 
-               WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",_new->server,_new->nick,_new->ident,_new->host, _new->GetIPString());
+               ServerInstance->WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",_new->server,_new->nick,_new->ident,_new->host, _new->GetIPString());
 
                params[7] = ":" + params[7];
                DoOneToAllButSender(source,"NICK",params,source);
@@ -1693,7 +1693,7 @@ class TreeSocket : public InspSocket
                 }
                /* XXX: Send each channel mode and its params -- we'll need a method for this in ModeHandler? */
                 //FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(c->second,(Module*)TreeProtocolModule,(void*)this));
-               this->WriteLine(":"+Srv->GetServerName()+" FMODE "+c->name+" "+ConvToStr(c->age)+" +"+chanmodes(c,true)+modes+" "+params);
+               this->WriteLine(":"+Srv->GetServerName()+" FMODE "+c->name+" "+ConvToStr(c->age)+" +"+c->ChanModes(true)+modes+" "+params);
        }
 
        /* Send G, Q, Z and E lines */
@@ -1814,7 +1814,7 @@ class TreeSocket : public InspSocket
                std::string endburst = "ENDBURST";
                // Because by the end of the netburst, it  could be gone!
                std::string name = s->GetName();
-               Srv->SendOpers("*** Bursting to \2"+name+"\2.");
+               ServerInstance->WriteOpers("*** Bursting to \2"+name+"\2.");
                this->WriteLine(burst);
                /* send our version string */
                this->WriteLine(":"+Srv->GetServerName()+" VERSION :"+Srv->GetVersion());
@@ -1827,7 +1827,7 @@ class TreeSocket : public InspSocket
                this->SendXLines(s);            
                FOREACH_MOD(I_OnSyncOtherMetaData,OnSyncOtherMetaData((Module*)TreeProtocolModule,(void*)this));
                this->WriteLine(endburst);
-               Srv->SendOpers("*** Finished bursting to \2"+name+"\2.");
+               ServerInstance->WriteOpers("*** Finished bursting to \2"+name+"\2.");
        }
 
        /* This function is called when we receive data from a remote
@@ -1923,7 +1923,7 @@ class TreeSocket : public InspSocket
        {
                if (params.size() < 1)
                        return false;
-               WriteOpers("*** ERROR from %s: %s",(InboundServerName != "" ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
+               ServerInstance->WriteOpers("*** ERROR from %s: %s",(InboundServerName != "" ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
                /* we will return false to cause the socket to close. */
                return false;
        }
@@ -1939,7 +1939,7 @@ class TreeSocket : public InspSocket
                        {
                                /* It's for our server */
                                string_list results;
-                               userrec* source = Srv->FindNick(prefix);
+                               userrec* source = ServerInstance->FindNick(prefix);
                                if (source)
                                {
                                        std::deque<std::string> par;
@@ -1956,7 +1956,7 @@ class TreeSocket : public InspSocket
                        else
                        {
                                /* Pass it on */
-                               userrec* source = Srv->FindNick(prefix);
+                               userrec* source = ServerInstance->FindNick(prefix);
                                if (source)
                                        DoOneToOne(prefix, "STATS", params, params[1]);
                        }
@@ -1976,7 +1976,7 @@ class TreeSocket : public InspSocket
                        return true;
                }
                std::string opertype = params[0];
-               userrec* u = Srv->FindNick(prefix);
+               userrec* u = ServerInstance->FindNick(prefix);
                if (u)
                {
                        u->modes[UM_OPERATOR] = 1;
@@ -1994,7 +1994,7 @@ class TreeSocket : public InspSocket
                if (params.size() < 3)
                        return true;
 
-               userrec* u = Srv->FindNick(params[0]);
+               userrec* u = ServerInstance->FindNick(params[0]);
 
                if (u)
                {
@@ -2022,7 +2022,7 @@ class TreeSocket : public InspSocket
                if (params.size() < 2)
                        return true;
 
-               userrec* u = Srv->FindNick(params[0]);
+               userrec* u = ServerInstance->FindNick(params[0]);
 
                if (u)
                {
@@ -2041,7 +2041,7 @@ class TreeSocket : public InspSocket
 
                if (Srv->MatchText(Srv->GetServerName(),servermask))
                {
-                       Srv->SendOpers("*** Remote rehash initiated from server \002"+prefix+"\002.");
+                       ServerInstance->WriteOpers("*** Remote rehash initiated from server \002"+prefix+"\002.");
                        Srv->RehashServer();
                        ReadConfiguration(false);
                }
@@ -2055,8 +2055,8 @@ class TreeSocket : public InspSocket
                        return true;
 
                std::string nick = params[0];
-               userrec* u = Srv->FindNick(prefix);
-               userrec* who = Srv->FindNick(nick);
+               userrec* u = ServerInstance->FindNick(prefix);
+               userrec* who = ServerInstance->FindNick(nick);
 
                if (who)
                {
@@ -2103,7 +2103,7 @@ class TreeSocket : public InspSocket
                                 * dump the PONG reply back to their fd. If its a server, do nowt.
                                 * Services might want to send these s->s, but we dont need to yet.
                                 */
-                               userrec* u = Srv->FindNick(prefix);
+                               userrec* u = ServerInstance->FindNick(prefix);
 
                                if (u)
                                {
@@ -2135,7 +2135,7 @@ class TreeSocket : public InspSocket
                        }
                        else if (*(params[0].c_str()) == '#')
                        {
-                               chanrec* c = Srv->FindChannel(params[0]);
+                               chanrec* c = ServerInstance->FindChan(params[0]);
                                if (c)
                                {
                                        FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(TYPE_CHANNEL,c,params[1],params[2]));
@@ -2143,7 +2143,7 @@ class TreeSocket : public InspSocket
                        }
                        else if (*(params[0].c_str()) != '#')
                        {
-                               userrec* u = Srv->FindNick(params[0]);
+                               userrec* u = ServerInstance->FindNick(params[0]);
                                if (u)
                                {
                                        FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(TYPE_USER,u,params[1],params[2]));
@@ -2177,7 +2177,7 @@ class TreeSocket : public InspSocket
                if (params.size() < 1)
                        return true;
 
-               userrec* u = Srv->FindNick(prefix);
+               userrec* u = ServerInstance->FindNick(prefix);
 
                if (u)
                {
@@ -2217,7 +2217,7 @@ class TreeSocket : public InspSocket
                        break;
                        default:
                                /* Just in case... */
-                               Srv->SendOpers("*** \2WARNING\2: Invalid xline type '"+params[0]+"' sent by server "+prefix+", ignored!");
+                               ServerInstance->WriteOpers("*** \2WARNING\2: Invalid xline type '"+params[0]+"' sent by server "+prefix+", ignored!");
                                propogate = false;
                        break;
                }
@@ -2227,11 +2227,11 @@ class TreeSocket : public InspSocket
                {
                        if (atoi(params[4].c_str()))
                        {
-                               WriteOpers("*** %s Added %cLINE on %s to expire in %lu seconds (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),atoi(params[4].c_str()),params[5].c_str());
+                               ServerInstance->WriteOpers("*** %s Added %cLINE on %s to expire in %lu seconds (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),atoi(params[4].c_str()),params[5].c_str());
                        }
                        else
                        {
-                               WriteOpers("*** %s Added permenant %cLINE on %s (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),params[5].c_str());
+                               ServerInstance->WriteOpers("*** %s Added permenant %cLINE on %s (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),params[5].c_str());
                        }
                        params[5] = ":" + params[5];
                        DoOneToAllButSender(prefix,"ADDLINE",params,prefix);
@@ -2249,7 +2249,7 @@ class TreeSocket : public InspSocket
                if (params.size() < 1)
                        return true;
 
-               userrec* u = Srv->FindNick(prefix);
+               userrec* u = ServerInstance->FindNick(prefix);
 
                if (u)
                {
@@ -2266,7 +2266,7 @@ class TreeSocket : public InspSocket
                        return true;
 
                log(DEBUG,"In IDLE command");
-               userrec* u = Srv->FindNick(prefix);
+               userrec* u = ServerInstance->FindNick(prefix);
 
                if (u)
                {
@@ -2274,10 +2274,10 @@ class TreeSocket : public InspSocket
                        // an incoming request
                        if (params.size() == 1)
                        {
-                               userrec* x = Srv->FindNick(params[0]);
+                               userrec* x = ServerInstance->FindNick(params[0]);
                                if ((x) && (IS_LOCAL(x)))
                                {
-                                       userrec* x = Srv->FindNick(params[0]);
+                                       userrec* x = ServerInstance->FindNick(params[0]);
                                        log(DEBUG,"Got IDLE");
                                        char signon[MAXBUF];
                                        char idle[MAXBUF];
@@ -2300,7 +2300,7 @@ class TreeSocket : public InspSocket
                        else if (params.size() == 3)
                        {
                                std::string who_did_the_whois = params[0];
-                               userrec* who_to_send_to = Srv->FindNick(who_did_the_whois);
+                               userrec* who_to_send_to = ServerInstance->FindNick(who_did_the_whois);
                                if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
                                {
                                        log(DEBUG,"Got final IDLE");
@@ -2326,7 +2326,7 @@ class TreeSocket : public InspSocket
                if (params.size() < 2)
                        return true;
 
-               userrec* u = Srv->FindNick(params[0]);
+               userrec* u = ServerInstance->FindNick(params[0]);
 
                if (!u)
                        return true;
@@ -2353,7 +2353,7 @@ class TreeSocket : public InspSocket
                        // someone querying our time?
                        if (Srv->GetServerName() == params[0])
                        {
-                               userrec* u = Srv->FindNick(params[1]);
+                               userrec* u = ServerInstance->FindNick(params[1]);
                                if (u)
                                {
                                        char curtime[256];
@@ -2366,7 +2366,7 @@ class TreeSocket : public InspSocket
                        else
                        {
                                // not us, pass it on
-                               userrec* u = Srv->FindNick(params[1]);
+                               userrec* u = ServerInstance->FindNick(params[1]);
                                if (u)
                                        DoOneToOne(prefix,"TIME",params,params[0]);
                        }
@@ -2374,7 +2374,7 @@ class TreeSocket : public InspSocket
                else if (params.size() == 3)
                {
                        // a response to a previous TIME
-                       userrec* u = Srv->FindNick(params[1]);
+                       userrec* u = ServerInstance->FindNick(params[1]);
                        if ((u) && (IS_LOCAL(u)))
                        {
                        time_t rawtime = atol(params[2].c_str());
@@ -2444,14 +2444,14 @@ class TreeSocket : public InspSocket
                if (CheckDupe)
                {
                        this->WriteLine("ERROR :Server "+servername+" already exists!");
-                       Srv->SendOpers("*** Server connection from \2"+servername+"\2 denied, already exists");
+                       ServerInstance->WriteOpers("*** Server connection from \2"+servername+"\2 denied, already exists");
                        return false;
                }
                TreeServer* Node = new TreeServer(servername,description,ParentOfThis,NULL);
                ParentOfThis->AddChild(Node);
                params[3] = ":" + params[3];
                DoOneToAllButSender(prefix,"SERVER",params,prefix);
-               Srv->SendOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
+               ServerInstance->WriteOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
                return true;
        }
 
@@ -2468,7 +2468,7 @@ class TreeSocket : public InspSocket
                if (hops)
                {
                        this->WriteLine("ERROR :Server too far away for authentication");
-                       Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
+                       ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
                        return false;
                }
                std::string description = params[3];
@@ -2480,7 +2480,7 @@ class TreeSocket : public InspSocket
                                if (CheckDupe)
                                {
                                        this->WriteLine("ERROR :Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
-                                       Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
+                                       ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
                                        return false;
                                }
                                // Begin the sync here. this kickstarts the
@@ -2501,7 +2501,7 @@ class TreeSocket : public InspSocket
                        }
                }
                this->WriteLine("ERROR :Invalid credentials");
-               Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
+               ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
                return false;
        }
 
@@ -2518,7 +2518,7 @@ class TreeSocket : public InspSocket
                if (hops)
                {
                        this->WriteLine("ERROR :Server too far away for authentication");
-                       Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
+                       ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
                        return false;
                }
                std::string description = params[3];
@@ -2530,7 +2530,7 @@ class TreeSocket : public InspSocket
                                if (CheckDupe)
                                {
                                        this->WriteLine("ERROR :Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
-                                       Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
+                                       ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
                                        return false;
                                }
                                /* If the config says this link is encrypted, but the remote side
@@ -2540,10 +2540,10 @@ class TreeSocket : public InspSocket
                                if ((x->EncryptionKey != "") && (!this->ctx_in))
                                {
                                        this->WriteLine("ERROR :This link requires AES encryption to be enabled. Plaintext connection refused.");
-                                       Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, remote server did not enable AES.");
+                                       ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, remote server did not enable AES.");
                                        return false;
                                }
-                               Srv->SendOpers("*** Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] ("+description+")");
+                               ServerInstance->WriteOpers("*** Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] ("+description+")");
                                this->InboundServerName = sname;
                                this->InboundDescription = description;
                                // this is good. Send our details: Our server name and description and hopcount of 0,
@@ -2555,7 +2555,7 @@ class TreeSocket : public InspSocket
                        }
                }
                this->WriteLine("ERROR :Invalid credentials");
-               Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
+               ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
                return false;
        }
 
@@ -2608,7 +2608,7 @@ class TreeSocket : public InspSocket
                }
                else if ((this->ctx_in) && (command == "AES"))
                {
-                       WriteOpers("*** \2AES\2: Encryption already enabled on this connection yet %s is trying to enable it twice!",params[0].c_str());
+                       ServerInstance->WriteOpers("*** \2AES\2: Encryption already enabled on this connection yet %s is trying to enable it twice!",params[0].c_str());
                }
 
                switch (this->LinkState)
@@ -2676,13 +2676,13 @@ class TreeSocket : public InspSocket
                                                long delta = THEM-time(NULL);
                                                if ((delta < -600) || (delta > 600))
                                                {
-                                                       WriteOpers("*** \2ERROR\2: Your clocks are out by %d seconds (this is more than ten minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs(delta));
+                                                       ServerInstance->WriteOpers("*** \2ERROR\2: Your clocks are out by %d seconds (this is more than ten minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs(delta));
                                                        this->WriteLine("ERROR :Your clocks are out by "+ConvToStr(abs(delta))+" seconds (this is more than ten minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
                                                        return false;
                                                }
                                                else if ((delta < -60) || (delta > 60))
                                                {
-                                                       WriteOpers("*** \2WARNING\2: Your clocks are out by %d seconds, please consider synching your clocks.",abs(delta));
+                                                       ServerInstance->WriteOpers("*** \2WARNING\2: Your clocks are out by %d seconds, please consider synching your clocks.",abs(delta));
                                                }
                                        }
                                        this->LinkState = CONNECTED;
@@ -2734,7 +2734,7 @@ class TreeSocket : public InspSocket
                                if (prefix != "")
                                {
                                        std::string direction = prefix;
-                                       userrec* t = Srv->FindNick(prefix);
+                                       userrec* t = ServerInstance->FindNick(prefix);
                                        if (t)
                                        {
                                                direction = t->server;
@@ -2888,8 +2888,8 @@ class TreeSocket : public InspSocket
                                        std::string sourceserv = this->myhost;
                                        if (params.size() == 3)
                                        {
-                                               userrec* user = Srv->FindNick(params[1]);
-                                               chanrec* chan = Srv->FindChannel(params[0]);
+                                               userrec* user = ServerInstance->FindNick(params[1]);
+                                               chanrec* chan = ServerInstance->FindChan(params[0]);
                                                if (user && chan)
                                                {
                                                        if (!chan->ServerKickUser(user, params[2].c_str(), false))
@@ -2928,7 +2928,7 @@ class TreeSocket : public InspSocket
                                        {
                                                sourceserv = this->InboundServerName;
                                        }
-                                       WriteOpers("*** Received end of netburst from \2%s\2",sourceserv.c_str());
+                                       ServerInstance->WriteOpers("*** Received end of netburst from \2%s\2",sourceserv.c_str());
                                        return true;
                                }
                                else
@@ -2936,7 +2936,7 @@ class TreeSocket : public InspSocket
                                        // not a special inter-server command.
                                        // Emulate the actual user doing the command,
                                        // this saves us having a huge ugly parser.
-                                       userrec* who = Srv->FindNick(prefix);
+                                       userrec* who = ServerInstance->FindNick(prefix);
                                        std::string sourceserv = this->myhost;
                                        if (this->InboundServerName != "")
                                        {
@@ -2950,7 +2950,7 @@ class TreeSocket : public InspSocket
                                                         * already exist here. If it does, kill their copy,
                                                         * and our copy.
                                                         */
-                                                       userrec* x = Srv->FindNick(params[0]);
+                                                       userrec* x = ServerInstance->FindNick(params[0]);
                                                        if ((x) && (x != who))
                                                        {
                                                                std::deque<std::string> p;
@@ -2962,7 +2962,7 @@ class TreeSocket : public InspSocket
                                                                p.push_back("Nickname collision");
                                                                DoOneToMany(Srv->GetServerName(),"KILL",p);
                                                                userrec::QuitUser(this->Instance,x,"Nickname collision ("+prefix+" -> "+params[0]+")");
-                                                               userrec* y = Srv->FindNick(prefix);
+                                                               userrec* y = ServerInstance->FindNick(prefix);
                                                                if (y)
                                                                {
                                                                        userrec::QuitUser(this->Instance,y,"Nickname collision");
@@ -3019,7 +3019,7 @@ class TreeSocket : public InspSocket
        {
                if (this->LinkState == CONNECTING)
                {
-                       Srv->SendOpers("*** CONNECT: Connection to \002"+myhost+"\002 timed out.");
+                       ServerInstance->WriteOpers("*** CONNECT: Connection to \002"+myhost+"\002 timed out.");
                }
        }
 
@@ -3038,7 +3038,7 @@ class TreeSocket : public InspSocket
                {
                        Squit(s,"Remote host closed the connection");
                }
-               WriteOpers("Server '\2%s\2' closed the connection.",quitserver.c_str());
+               ServerInstance->WriteOpers("Server '\2%s\2' closed the connection.",quitserver.c_str());
        }
 
        virtual int OnIncomingConnection(int newsock, char* ip)
@@ -3058,7 +3058,7 @@ class TreeSocket : public InspSocket
 
                        if (!found)
                        {
-                               WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip);
+                               ServerInstance->WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip);
                                close(newsock);
                                return false;
                        }
@@ -3107,7 +3107,7 @@ class ServernameResolver : public Resolver
                        else
                        {
                                /* Something barfed, show the opers */
-                               WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
+                               ServerInstance->WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
                                delete newsocket;
                        }
                }
@@ -3116,7 +3116,7 @@ class ServernameResolver : public Resolver
        void OnError(ResolverError e, const std::string &errormessage)
        {
                /* Ooops! */
-               WriteOpers("*** CONNECT: Error connecting \002%s\002: Unable to resolve hostname - %s",MyLink.Name.c_str(),errormessage.c_str());
+               ServerInstance->WriteOpers("*** CONNECT: Error connecting \002%s\002: Unable to resolve hostname - %s",MyLink.Name.c_str(),errormessage.c_str());
        }
 };
 
@@ -3184,7 +3184,7 @@ bool DoOneToAllButSenderRaw(std::string data, std::string omit, std::string pref
                        if ((*(params[0].c_str()) != '#') && (*(params[0].c_str()) != '$'))
                        {
                                // special routing for private messages/notices
-                               userrec* d = Srv->FindNick(params[0]);
+                               userrec* d = ServerInstance->FindNick(params[0]);
                                if (d)
                                {
                                        std::deque<std::string> par;
@@ -3205,7 +3205,7 @@ bool DoOneToAllButSenderRaw(std::string data, std::string omit, std::string pref
                        else
                        {
                                log(DEBUG,"Channel privmsg going to chan %s",params[0].c_str());
-                               chanrec* c = Srv->FindChannel(params[0]);
+                               chanrec* c = ServerInstance->FindChan(params[0]);
                                if (c)
                                {
                                        std::deque<TreeServer*> list;
@@ -3666,7 +3666,7 @@ class ModuleSpanningTree : public Module
                        if (sock)
                        {
                                log(DEBUG,"Splitting server %s",s->GetName().c_str());
-                               WriteOpers("*** SQUIT: Server \002%s\002 removed from network by %s",parameters[0],user->nick);
+                               ServerInstance->WriteOpers("*** SQUIT: Server \002%s\002 removed from network by %s",parameters[0],user->nick);
                                sock->Squit(s,"Server quit by "+std::string(user->nick)+"!"+std::string(user->ident)+"@"+std::string(user->host));
                                Srv->RemoveSocket(sock);
                        }
@@ -3710,7 +3710,7 @@ class ModuleSpanningTree : public Module
        {
                if ((IS_LOCAL(user)) && (pcnt > 1))
                {
-                       userrec* remote = Srv->FindNick(parameters[1]);
+                       userrec* remote = ServerInstance->FindNick(parameters[1]);
                        if ((remote) && (remote->fd < 0))
                        {
                                std::deque<std::string> params;
@@ -3746,7 +3746,7 @@ class ModuleSpanningTree : public Module
                                        else
                                        {
                                                // they didnt answer, boot them
-                                               WriteOpers("*** Server \002%s\002 pinged out",serv->GetName().c_str());
+                                               ServerInstance->WriteOpers("*** Server \002%s\002 pinged out",serv->GetName().c_str());
                                                sock->Squit(serv,"Ping timeout");
                                                Srv->RemoveSocket(sock);
                                                return;
@@ -3768,7 +3768,7 @@ class ModuleSpanningTree : public Module
                                if (!CheckDupe)
                                {
                                        // an autoconnected server is not connected. Check if its time to connect it
-                                       WriteOpers("*** AUTOCONNECT: Auto-connecting server \002%s\002 (%lu seconds until next attempt)",x->Name.c_str(),x->AutoConnect);
+                                       ServerInstance->WriteOpers("*** AUTOCONNECT: Auto-connecting server \002%s\002 (%lu seconds until next attempt)",x->Name.c_str(),x->AutoConnect);
 
                                        insp_inaddr binip;
 
@@ -3782,7 +3782,7 @@ class ModuleSpanningTree : public Module
                                                }
                                                else
                                                {
-                                                       WriteOpers("*** AUTOCONNECT: Error autoconnecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
+                                                       ServerInstance->WriteOpers("*** AUTOCONNECT: Error autoconnecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
                                                        delete newsocket;
                                                }
                                        }
@@ -3863,7 +3863,7 @@ class ModuleSpanningTree : public Module
                                                }
                                                else
                                                {
-                                                       WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
+                                                       ServerInstance->WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
                                                        delete newsocket;
                                                }
                                        }
@@ -3902,7 +3902,7 @@ class ModuleSpanningTree : public Module
                                results.push_back(Srv->GetServerName()+" 244 "+user->nick+" H * * "+LinkBlocks[i].Name.c_str());
                        }
                        results.push_back(Srv->GetServerName()+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
-                       WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
+                       ServerInstance->WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
                        return 1;
                }
                return 0;
@@ -4275,7 +4275,7 @@ class ModuleSpanningTree : public Module
                        // check for self
                        if (Srv->MatchText(Srv->GetServerName(),parameter))
                        {
-                               Srv->SendOpers("*** Remote rehash initiated from server \002"+Srv->GetServerName()+"\002.");
+                               ServerInstance->WriteOpers("*** Remote rehash initiated from server \002"+Srv->GetServerName()+"\002.");
                                Srv->RehashServer();
                        }
                }
@@ -4461,14 +4461,14 @@ class ModuleSpanningTree : public Module
                                return;
                        // Insert the TS value of the object, either userrec or chanrec
                        time_t ourTS = 0;
-                       userrec* a = Srv->FindNick((*params)[0]);
+                       userrec* a = ServerInstance->FindNick((*params)[0]);
                        if (a)
                        {
                                ourTS = a->age;
                        }
                        else
                        {
-                               chanrec* a = Srv->FindChannel((*params)[0]);
+                               chanrec* a = ServerInstance->FindChan((*params)[0]);
                                if (a)
                                {
                                        ourTS = a->age;
index 40be036ab1207049344260ff0e91f6d52280a9d6..041814f9b87e50726b171b325a7e28defda61c39 100644 (file)
@@ -94,11 +94,11 @@ class cmd_spylist : public command_t
 
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick);
+               ServerInstance->WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick);
                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,i->second->GetUserCounter(),chanmodes(i->second,true),i->second->topic);
+                       user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,i->second->GetUserCounter(),i->second->ChanModes(true),i->second->topic);
                }
                user->WriteServ("323 %s :End of channel list.",user->nick);
        }
@@ -126,9 +126,9 @@ class cmd_spynames : public command_t
                if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 1))
                        return;
 
-               WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
+               ServerInstance->WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
 
-               c = FindChan(parameters[0]);
+               c = ServerInstance->FindChan(parameters[0]);
                if (c)
                {
                        spy_userlist(user,c);
index cb400a0bf64e7fa048f3ee11a0f64e07197faf04..35ffd6d8f453013b0e8c140ce883e2badd647f73 100644 (file)
@@ -22,6 +22,8 @@
 
 /* $ModDesc: Provides the SWHOIS command which allows setting of arbitary WHOIS lines */
 
+extern InspIRCd* ServerInstance;
+
 class cmd_swhois : public command_t
 {
        Server* Srv;
@@ -35,7 +37,7 @@ class cmd_swhois : public command_t
 
        void Handle(const char** parameters, int pcnt, userrec* user)
        {
-               userrec* dest = Srv->FindNick(std::string(parameters[0]));
+               userrec* dest = ServerInstance->FindNick(parameters[0]);
                if(dest)
                {
                        std::string line;
@@ -56,7 +58,7 @@ class cmd_swhois : public command_t
                                
                                if (!Srv->IsUlined(user->server))
                                        // Ulines set SWHOISes silently
-                                       WriteOpers("*** %s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick, dest->nick, text->c_str(), line.c_str());
+                                       ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick, dest->nick, text->c_str(), line.c_str());
                                
                                dest->Shrink("swhois");
                                DELETE(text);
@@ -64,7 +66,7 @@ class cmd_swhois : public command_t
                        else if(!Srv->IsUlined(user->server))
                        {
                                // Ulines set SWHOISes silently
-                               WriteOpers("*** %s used SWHOIS to set %s's extra whois to '%s'", user->nick, dest->nick, line.c_str());
+                               ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois to '%s'", user->nick, dest->nick, line.c_str());
                        }
                        
                        text = new std::string(line);
index 426859390686ac0a0016014bded906c833c9d2f8..14e68dfdab478a83e048cde4a4d0753a03b78199 100644 (file)
@@ -52,7 +52,7 @@ class cmd_tban : public command_t
 
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               chanrec* channel = Srv->FindChannel(parameters[0]);
+               chanrec* channel = ServerInstance->FindChan(parameters[0]);
                if (channel)
                {
                        std::string cm = Srv->ChanMode(user,channel);
@@ -159,7 +159,7 @@ class ModuleTimedBans : public Module
                        {
                                if (curtime > i->expire)
                                {
-                                       chanrec* cr = Srv->FindChannel(i->channel);
+                                       chanrec* cr = ServerInstance->FindChan(i->channel);
                                        again = true;
                                        if (cr)
                                        {
index bde81011dd1729a2e322adc22b07c59a933b8984..8d8d46c479a374a5a185221cdfd4355c6b6bba12 100644 (file)
@@ -24,8 +24,10 @@ using namespace std;
 #include "modules.h"
 #include "helperfuncs.h"
 #include "message.h"
+#include "inspircd.h"
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
         
 class cmd_uninvite : public command_t
 {
@@ -38,8 +40,8 @@ class cmd_uninvite : public command_t
 
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               userrec* u = Find(parameters[0]);
-               chanrec* c = FindChan(parameters[1]);
+               userrec* u = ServerInstance->FindNick(parameters[0]);
+               chanrec* c = ServerInstance->FindChan(parameters[1]);
                         
                if ((!c) || (!u))
                {       
index 1ad0e1c585d8514efcdd7aae9c51197b67a135a8..80ab67be1e6dce4f2b0249f29741c095f446897a 100644 (file)
@@ -22,10 +22,12 @@ using namespace std;
 #include "channels.h"
 #include "modules.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides support for USERIP command */
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
 
 class cmd_userip : public command_t
 {
@@ -42,7 +44,7 @@ class cmd_userip : public command_t
                snprintf(Return,MAXBUF,"340 %s :",user->nick);
                for (int i = 0; i < pcnt; i++)
                {
-                       userrec *u = Find(parameters[i]);
+                       userrec *u = ServerInstance->FindNick(parameters[i]);
                        if (u)
                        {
                                snprintf(junk,MAXBUF,"%s%s=+%s@%s ",u->nick,*u->oper ? "*" : "",u->ident,u->GetIPString());
index 2ba9c9afb1bc1c2964be5d830d55a85d9c3013d5..8e6b2c50ca5d003ad4420142da70694fdfcebffd 100644 (file)
@@ -29,6 +29,7 @@ using namespace std;
 /* $ModDesc: Provides support for the /watch command */
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
 
 class watchentry : public classbase
 {
@@ -58,7 +59,7 @@ class cmd_watch : public command_t
                                watchentry* a = (watchentry*)(*q);
                                if (a->watcher == user)
                                {
-                                       userrec* targ = Srv->FindNick(a->target);
+                                       userrec* targ = ServerInstance->FindNick(a->target);
                                        if (targ)
                                        {
                                                user->WriteServ("604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age);
@@ -99,7 +100,7 @@ class cmd_watch : public command_t
                                                watchentry* a = (watchentry*)(*q);
                                                if (a->watcher == user)
                                                {
-                                                       userrec* targ = Srv->FindNick(a->target);
+                                                       userrec* targ = ServerInstance->FindNick(a->target);
                                                        if (targ)
                                                        {
                                                                user->WriteServ("604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age);
@@ -136,7 +137,7 @@ class cmd_watch : public command_t
                                                if (b->watcher == user)
                                                {
                                                        irc::string n2 = b->target.c_str();
-                                                       userrec* a = Srv->FindNick(b->target);
+                                                       userrec* a = ServerInstance->FindNick(b->target);
                                                        if (a)
                                                        {
                                                                user->WriteServ("602 %s %s %s %s %lu :stopped watching",user->nick,a->nick,a->ident,a->dhost,a->age);
@@ -180,7 +181,7 @@ class cmd_watch : public command_t
                                                watches.push_back(w);
                                                log(DEBUG,"*** Added %s to watchlist of %s",nick,user->nick);
                                        }
-                                       userrec* a = Srv->FindNick(nick);
+                                       userrec* a = ServerInstance->FindNick(nick);
                                        if (a)
                                        {
                                                user->WriteServ("604 %s %s %s %s %lu :is online",user->nick,a->nick,a->ident,a->dhost,a->age);
index 42c3bd3db49aff8bd84fc971eb4a9a19e978b42c..51235b8825f66992b7c150e8a377fb32a17e7182 100644 (file)
@@ -19,7 +19,6 @@
 using namespace std;
 
 #include "inspircd_config.h"
-#include "inspircd.h"
 #include "configreader.h"
 #include <unistd.h>
 #include <fcntl.h>
@@ -48,6 +47,7 @@ using namespace std;
 #include "hashcomp.h"
 #include "socketengine.h"
 #include "userprocess.h"
+#include "inspircd.h"
 #include "typedefs.h"
 #include "command_parse.h"
 #include "cull_list.h"
@@ -146,7 +146,7 @@ void InspIRCd::ProcessUser(userrec* cu)
                                        if (current->lines_in > current->flood)
                                        {
                                                log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
-                                               WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
+                                               this->WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
                                                userrec::QuitUser(this, current,"Excess flood");
                                                return;
                                        }
@@ -158,7 +158,7 @@ void InspIRCd::ProcessUser(userrec* cu)
                                }
                                else
                                {
-                                       WriteOpers("*** Excess flood from %s",current->GetIPString());
+                                       this->WriteOpers("*** Excess flood from %s",current->GetIPString());
                                        log(DEFAULT,"Excess flood from: %s",current->GetIPString());
                                        add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
                                        apply_lines(APPLY_ZLINES);
@@ -175,7 +175,7 @@ void InspIRCd::ProcessUser(userrec* cu)
                                }
                                else
                                {
-                                       WriteOpers("*** Excess flood from %s",current->GetIPString());
+                                       this->WriteOpers("*** Excess flood from %s",current->GetIPString());
                                        log(DEFAULT,"Excess flood from: %s",current->GetIPString());
                                        add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
                                        apply_lines(APPLY_ZLINES);
index 7fcda61a9232aee4b5ef7c64112520d5601d40cf..baef05e28043a6ee31144eaababf6ba1a6b9b390 100644 (file)
@@ -497,7 +497,7 @@ bool userrec::AddBuffer(const std::string &a)
        if (recvq.length() > (unsigned)this->recvqmax)
        {
                this->SetWriteError("RecvQ exceeded");
-               WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
+               ServerInstance->WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
                return false;
        }
 
@@ -554,7 +554,7 @@ void userrec::AddWriteBuf(const std::string &data)
                 * to repeatedly add the text to the sendq!
                 */
                this->SetWriteError("SendQ exceeded");
-               WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
+               ServerInstance->WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
                return;
        }
        
@@ -664,7 +664,7 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit
 
        if (user->registered == REG_ALL)
        {
-               purge_empty_chans(user);
+               user->PurgeEmptyChannels();
                FOREACH_MOD_I(Instance,I_OnUserQuit,OnUserQuit(user,reason));
                user->WriteCommonExcept("QUIT :%s",reason.c_str());
        }
@@ -693,7 +693,7 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit
        }
 
        /*
-        * this must come before the WriteOpers so that it doesnt try to fill their buffer with anything
+        * this must come before the ServerInstance->WriteOpers so that it doesnt try to fill their buffer with anything
         * if they were an oper with +s.
         *
         * XXX -
@@ -703,7 +703,7 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit
        if (user->registered == REG_ALL)
        {
                if (IS_LOCAL(user))
-                       WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
+                       Instance->WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
                user->AddToWhoWas();
        }
 
@@ -970,7 +970,7 @@ void userrec::FullConnect(CullList* Goners)
        ServerInstance->stats->statsConnects++;
        this->idle_lastmsg = TIME;
 
-       ConnectClass a = GetClass(this);
+       ConnectClass a = this->GetClass();
 
        if (a.type == CC_DENY)
        {
@@ -987,13 +987,13 @@ void userrec::FullConnect(CullList* Goners)
        if (this->LocalCloneCount() > a.maxlocal)
        {
                Goners->AddItem(this, "No more connections allowed from your host via this connect class (local)");
-               WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a.maxlocal, this->GetIPString());
+               ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a.maxlocal, this->GetIPString());
                return;
        }
        else if (this->GlobalCloneCount() > a.maxglobal)
        {
                Goners->AddItem(this, "No more connections allowed from your host via this connect class (global)");
-               WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a.maxglobal, this->GetIPString());
+               ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a.maxglobal, this->GetIPString());
                return;
        }
 
@@ -1061,7 +1061,7 @@ void userrec::FullConnect(CullList* Goners)
        FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
        FOREACH_MOD(I_OnGlobalConnect,OnGlobalConnect(this));
        this->registered = REG_ALL;
-       WriteOpers("*** Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
+       ServerInstance->WriteOpers("*** Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
 }
 
 /** userrec::UpdateNick()
@@ -1713,3 +1713,53 @@ void userrec::SplitChanList(userrec* dest, const std::string &cl)
 }
 
 
+/* 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,
+ * <connect allow="127.0.0.1"> will match joe!bloggs@localhost
+ */
+ConnectClass& userrec::GetClass()
+{
+        for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
+        {
+                if ((match(this->GetIPString(),i->host.c_str(),true)) || (match(this->host,i->host.c_str())))
+                        return *i;
+        }
+
+        return *(ServerInstance->Config->Classes.begin());
+}
+
+void userrec::PurgeEmptyChannels()
+{
+        std::vector<chanrec*> to_delete;
+
+        // firstly decrement the count on each channel
+        for (std::vector<ucrec*>::iterator f = this->chans.begin(); f != this->chans.end(); f++)
+        {
+                ucrec* uc = *f;
+                if (uc->channel)
+                {
+                        if (uc->channel->DelUser(this) == 0)
+                        {
+                                /* No users left in here, mark it for deletion */
+                                to_delete.push_back(uc->channel);
+                                uc->channel = NULL;
+                        }
+                }
+        }
+
+        for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
+        {
+                chanrec* thischan = *n;
+                chan_hash::iterator i2 = ServerInstance->chanlist.find(thischan->name);
+                if (i2 != ServerInstance->chanlist.end())
+                {
+                        FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
+                        DELETE(i2->second);
+                        ServerInstance->chanlist.erase(i2);
+                }
+        }
+
+        this->UnOper();
+}
+
index d3821b528147c2a66b05c43782823d4064379c41..551e98458da906150a21228e25ee5899933a9408 100644 (file)
@@ -617,35 +617,35 @@ void expire_lines()
        while ((glines.size()) && (current > (glines.begin()->duration + glines.begin()->set_time)))
        {
                std::vector<GLine>::iterator i = glines.begin();
-               WriteOpers("*** Expiring timed G-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
+               ServerInstance->WriteOpers("*** Expiring timed G-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
                glines.erase(i);
        }
 
        while ((elines.size()) && (current > (elines.begin()->duration + elines.begin()->set_time)))
        {
                std::vector<ELine>::iterator i = elines.begin();
-               WriteOpers("*** Expiring timed E-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
+               ServerInstance->WriteOpers("*** Expiring timed E-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
                elines.erase(i);
        }
 
        while ((zlines.size()) && (current > (zlines.begin()->duration + zlines.begin()->set_time)))
        {
                std::vector<ZLine>::iterator i = zlines.begin();
-               WriteOpers("*** Expiring timed Z-Line %s (set by %s %d seconds ago)",i->ipaddr,i->source,i->duration);
+               ServerInstance->WriteOpers("*** Expiring timed Z-Line %s (set by %s %d seconds ago)",i->ipaddr,i->source,i->duration);
                zlines.erase(i);
        }
 
        while ((klines.size()) && (current > (klines.begin()->duration + klines.begin()->set_time)))
        {
                std::vector<KLine>::iterator i = klines.begin();
-               WriteOpers("*** Expiring timed K-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
+               ServerInstance->WriteOpers("*** Expiring timed K-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
                klines.erase(i);
        }
 
        while ((qlines.size()) && (current > (qlines.begin()->duration + qlines.begin()->set_time)))
        {
                std::vector<QLine>::iterator i = qlines.begin();
-               WriteOpers("*** Expiring timed Q-Line %s (set by %s %d seconds ago)",i->nick,i->source,i->duration);
+               ServerInstance->WriteOpers("*** Expiring timed Q-Line %s (set by %s %d seconds ago)",i->nick,i->source,i->duration);
                qlines.erase(i);
        }