]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Logging
[user/henk/code/inspircd.git] / src / users.cpp
index 94ed97d93f9b3b0f4df0c0defb63bcd8ebc62c88..c7f74da0b95b0ac8f2ee0cd374778984adc5a23a 100644 (file)
@@ -62,42 +62,49 @@ typedef opertype_t operclass_t;
 opertype_t opertypes;
 operclass_t operclass;
 
-void ReadClassesAndTypes()
+bool InitTypes(const char* tag)
 {
-       char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
        for (opertype_t::iterator n = opertypes.begin(); n != opertypes.end(); n++)
        {
                if (n->second)
                        delete[] n->second;
        }
+       opertypes.clear();
+       return true;
+}
+
+bool InitClasses(const char* tag)
+{
        for (operclass_t::iterator n = operclass.begin(); n != operclass.end(); n++)
        {
                if (n->second)
                        delete[] n->second;
        }
-       opertypes.clear();
        operclass.clear();
-       for (int j =0; j < Config->ConfValueEnum("type",&Config->config_f); j++)
-       {
-               Config->ConfValue("type","name",j,TypeName,&Config->config_f);
-               Config->ConfValue("type","classes",j,Classes,&Config->config_f);
-               opertypes[TypeName] = strdup(Classes);
-               log(DEBUG,"Read oper TYPE '%s' with classes '%s'",TypeName,Classes);
-       }
-       for (int k =0; k < Config->ConfValueEnum("class",&Config->config_f); k++)
-       {
-               Config->ConfValue("class","name",k,ClassName,&Config->config_f);
-               Config->ConfValue("class","commands",k,CommandList,&Config->config_f);
-               operclass[ClassName] = strdup(CommandList);
-               log(DEBUG,"Read oper CLASS '%s' with commands '%s'",ClassName,CommandList);
-       }
+       return true;
 }
 
-template<typename T> inline string ConvToStr(const T &in)
+bool DoType(const char* tag, char** entries, void** values, int* types)
 {
-        stringstream tmp;
-        if (!(tmp << in)) return string();
-        return tmp.str();
+       char* TypeName = (char*)values[0];
+       char* Classes = (char*)values[1];
+       opertypes[TypeName] = strdup(Classes);
+       log(DEBUG,"Read oper TYPE '%s' with classes '%s'",TypeName,Classes);
+       return true;
+}
+
+bool DoClass(const char* tag, char** entries, void** values, int* types)
+{
+       char* ClassName = (char*)values[0];
+       char* CommandList = (char*)values[1];
+       operclass[ClassName] = strdup(CommandList);
+       log(DEBUG,"Read oper CLASS '%s' with commands '%s'",ClassName,CommandList);
+       return true;
+}
+
+bool DoneClassesAndTypes(const char* tag)
+{
+       return true;
 }
 
 userrec::userrec()
@@ -107,16 +114,29 @@ userrec::userrec()
        server = (char*)FindServerNamePtr(Config->ServerName);
        reset_due = TIME;
        lines_in = fd = lastping = signon = idle_lastmsg = nping = registered = 0;
-       timeout = flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
+       modebits = 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);
+        for (unsigned int n = 0; n < MAXCHANS; n++)
+        {
+               ucrec* x = new ucrec();
+               chans[n] = x;
+               x->channel = NULL;
+               x->uc_modes = 0;
+        }
 }
 
 userrec::~userrec()
 {
+       for (std::vector<ucrec*>::iterator n = chans.begin(); n != chans.end(); n++)
+       {
+               ucrec* x = (ucrec*)*n;
+               delete x;
+       }
 }
 
 void userrec::MakeHost(char* nhost)
@@ -233,7 +253,7 @@ void userrec::RemoveInvite(irc::string &channel)
                }
 }
 
-bool userrec::HasPermission(std::string &command)
+bool userrec::HasPermission(const std::string &command)
 {
        char* mycmd;
        char* savept;
@@ -282,7 +302,7 @@ bool userrec::HasPermission(std::string &command)
 }
 
 
-bool userrec::AddBuffer(std::string a)
+bool userrec::AddBuffer(const std::string &a)
 {
         std::string b = "";
        char* n = (char*)a.c_str();
@@ -342,9 +362,9 @@ std::string userrec::GetBuffer()
         return ret;
 }
 
-void userrec::AddWriteBuf(std::string data)
+void userrec::AddWriteBuf(const std::string &data)
 {
-       if (this->GetWriteError() != "")
+       if (*this->GetWriteError())
                return;
        if (sendq.length() + data.length() > (unsigned)this->sendqmax)
        {
@@ -384,7 +404,7 @@ void userrec::FlushWriteBuf()
        }
 }
 
-void userrec::SetWriteError(std::string error)
+void userrec::SetWriteError(const std::string &error)
 {
        log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str());
        // don't try to set the error twice, its already set take the first string.
@@ -392,9 +412,9 @@ void userrec::SetWriteError(std::string error)
                this->WriteError = error;
 }
 
-std::string userrec::GetWriteError()
+const char* userrec::GetWriteError()
 {
-       return this->WriteError;
+       return this->WriteError.c_str();
 }
 
 void AddOper(userrec* user)
@@ -616,11 +636,6 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4)
         clientlist[tempnick]->sendqmax = class_sqmax;
         clientlist[tempnick]->recvqmax = class_rqmax;
 
-        ucrec a;
-        a.channel = NULL;
-        a.uc_modes = 0;
-       clientlist[tempnick]->chans.resize(MAXCHANS);
-
        fd_ref_table[socket] = clientlist[tempnick];
        local_users.push_back(clientlist[tempnick]);
 
@@ -841,4 +856,3 @@ void force_nickchange(userrec* user,const char* newnick)
                 }
         }
 }
-