]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
FIX channel user count stuff. next to do, order the user count list
[user/henk/code/inspircd.git] / src / users.cpp
index be24db6971007336981749ea2ff23d2df3b73eb1..f455bb8251e44bc985b2394b4cc5ee3a23e31a2a 100644 (file)
@@ -14,9 +14,8 @@
  * ---------------------------------------------------
  */
 
-using namespace std;
-
-#include "inspircd_config.h" 
+#include "inspircd_config.h"
+#include "configreader.h"
 #include "channels.h"
 #include "connection.h"
 #include "users.h"
@@ -111,20 +110,98 @@ bool DoneClassesAndTypes(const char* tag)
        return true;
 }
 
+bool userrec::ProcessNoticeMasks(const char *sm)
+{
+       bool adding = true;
+       const char *c = sm;
+
+       while (c && *c)
+       {
+               switch (*c)
+               {
+                       case '+':
+                               adding = true;
+                               break;
+                       case '-':
+                               adding = false;
+                               break;
+                       default:
+                               if ((*c >= 'A') && (*c <= 'z'))
+                                       this->SetNoticeMask(*c, adding);
+                               break;
+               }
+
+               *c++;
+       }
+
+       return true;
+}
+
+bool userrec::IsNoticeMaskSet(unsigned char sm)
+{
+       return (snomasks[sm-65]);
+}
+
+void userrec::SetNoticeMask(unsigned char sm, bool value)
+{
+       snomasks[sm-65] = value;
+}
+
+const char* userrec::FormatNoticeMasks()
+{
+       static char data[MAXBUF];
+       int offset = 0;
+
+       for (int n = 0; n < 64; n++)
+       {
+               if (snomasks[n])
+                       data[offset++] = n+65;
+       }
+
+       data[offset] = 0;
+       return data;
+}
+
+
+
+bool userrec::IsModeSet(unsigned char m)
+{
+       return (modes[m-65]);
+}
+
+void userrec::SetMode(unsigned char m, bool value)
+{
+       modes[m-65] = value;
+}
+
+const char* userrec::FormatModes()
+{
+       static char data[MAXBUF];
+       int offset = 0;
+       for (int n = 0; n < 64; n++)
+       {
+               if (modes[n])
+                       data[offset++] = n+65;
+       }
+       data[offset] = 0;
+       return data;
+}
+
 userrec::userrec()
 {
        // the PROPER way to do it, AVOID bzero at *ALL* costs
-       *password = *nick = *ident = *host = *dhost = *fullname = *modes = *awaymsg = *oper = 0;
+       *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = 0;
        server = (char*)FindServerNamePtr(Config->ServerName);
        reset_due = TIME;
        lines_in = fd = lastping = signon = idle_lastmsg = nping = registered = 0;
-       modebits = timeout = flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
+       timeout = flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
        haspassed = dns_done = false;
        recvq = "";
        sendq = "";
        chans.clear();
        invites.clear();
        chans.resize(MAXCHANS);
+       memset(modes,0,sizeof(modes));
        
        for (unsigned int n = 0; n < MAXCHANS; n++)
        {
@@ -140,7 +217,7 @@ userrec::~userrec()
        for (std::vector<ucrec*>::iterator n = chans.begin(); n != chans.end(); n++)
        {
                ucrec* x = (ucrec*)*n;
-               delete x;
+               DELETE(x);
        }
 }
 
@@ -404,9 +481,8 @@ void userrec::AddWriteBuf(const std::string &data)
                WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
                return;
        }
-       std::stringstream stream;
-       stream << sendq << data;
-       sendq = stream.str();
+       
+       sendq.append(data);
 }
 
 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)
@@ -418,7 +494,8 @@ void userrec::FlushWriteBuf()
                int n_sent = write(this->fd,tb,this->sendq.length());
                if (n_sent == -1)
                {
-                       this->SetWriteError(strerror(errno));
+                       if (errno != EAGAIN)
+                               this->SetWriteError(strerror(errno));
                }
                else
                {
@@ -482,7 +559,7 @@ void kill_link(userrec *user,const char* r)
        char reason[MAXBUF];
 
        strlcpy(reason,r,MAXQUIT-1);
-       log(DEBUG,"kill_link: %s '%s'",user->nick,reason);
+       log(DEBUG,"kill_link: %s %d '%s'",user->nick,user->fd,reason);
        
        if (IS_LOCAL(user))
                Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason);
@@ -545,7 +622,7 @@ void kill_link(userrec *user,const char* r)
                        }
                }
                clientlist.erase(iter);
-               delete user;
+               DELETE(user);
        }
 }
 
@@ -589,7 +666,7 @@ void AddWhoWas(userrec* u)
                if (group->size() > 10)
                {
                        WhoWasGroup *a = (WhoWasGroup*)*(group->begin());
-                       delete a;
+                       DELETE(a);
                        group->pop_front();
                }
                
@@ -609,7 +686,7 @@ void MaintainWhoWas(time_t TIME)
                        while ((n->begin() != n->end()) && ((*n->begin())->signon < TIME - 259200)) // 3 days
                        {
                                WhoWasGroup *a = *(n->begin());
-                               delete a;
+                               DELETE(a);
                                n->erase(n->begin());
                        }
                }
@@ -636,7 +713,7 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4)
        if (iter != clientlist.end())
        {
                userrec* goner = iter->second;
-               delete goner;
+               DELETE(goner);
                clientlist.erase(iter);
        }
 
@@ -732,7 +809,10 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4)
                }
        }
 
-       ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT);
+       if (socket > -1)
+       {
+               ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT);
+       }
 
        WriteServ(clientlist[tempnick]->fd,"NOTICE Auth :*** Looking up your hostname...");
 }
@@ -809,7 +889,7 @@ void FullConnectUser(userrec* user, CullList* Goners)
                        return;
                }
                
-               r = matches_kline(user->host);
+               r = matches_kline(match_against);
                
                if (r)
                {