]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add max line length value to modestacker, so that it can clamp the max length of...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 25 Feb 2007 00:11:46 +0000 (00:11 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 25 Feb 2007 00:11:46 +0000 (00:11 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6609 e03df62e-2008-0410-955e-edbf42e46eb7

include/hashcomp.h
src/hashcomp.cpp
src/modules/m_conn_waitpong.cpp

index b7f8d95389533af87118baa622fbd4c5198e4dad..323b35980b24dfa331a53e4d5f76ee8b7bc6796f 100644 (file)
@@ -185,12 +185,20 @@ namespace irc
                /** Return zero or more elements which form the
                 * mode line. This will be clamped to a max of
                 * MAXMODES+1 items (MAXMODES mode parameters and
-                * one mode sequence string).
+                * one mode sequence string), and max_line_size
+                * characters. As specified below, this function
+                * should be called in a loop until it returns zero,
+                * indicating there are no more modes to return.
                 * @param result The deque to populate. This will
                 * be cleared before it is used.
-                * @return The number of elements in the deque
-                */
-               int GetStackedLine(std::deque<std::string> &result);
+                * @param max_line_size The maximum size of the line
+                * to build, in characters, seperate to MAXMODES.
+                * @return The number of elements in the deque.
+                * The function should be called repeatedly until it
+                * returns 0, in case there are multiple lines of
+                * mode changes to be obtained.
+                */
+               int GetStackedLine(std::deque<std::string> &result, int max_line_size = 360);
        };
 
        /** irc::tokenstream reads a string formatted as per RFC1459 and RFC2812.
index 060d78fe2f8a389db2c1d862cac674692021fddb..f927fbc99e683d6f6963d46bf185899f55bdd31f 100644 (file)
@@ -335,19 +335,37 @@ void irc::modestacker::PushMinus()
        this->Push('-',"");
 }
 
-int irc::modestacker::GetStackedLine(std::deque<std::string> &result)
+int irc::modestacker::GetStackedLine(std::deque<std::string> &result, int max_line_size)
 {
+       if (sequence.empty())
+       {
+               result.clear();
+               return 0;
+       }
+
        int n = 0;
+       int size = 1; /* Account for initial +/- char */
+       int nextsize = 0;
        result.clear();
        result.push_back(adding ? "+" : "-");
 
-       while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES+1))
+       if (sequence.size() > 1)
+               nextsize = sequence[1].length();
+
+       while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES+1) && ((size+nextsize) < max_line_size))
        {
                result[0] += *(sequence[0].begin());
                if (!sequence[1].empty())
+               {
                        result.push_back(sequence[1]);
+                       size += sequence[1].length() + 2; /* Account for mode character and whitespace */
+               }
                sequence[0].erase(sequence[0].begin());
                sequence.erase(sequence.begin() + 1);
+
+               if (sequence.size() > 1)
+                       nextsize = sequence[1].length();
+
                n++;
        }
 
index e6e6456ff419b160863f9bfdac47b0914ca5f20f..d7a4b833a02daa9349d64b5f705557a01e2202f9 100644 (file)
@@ -81,19 +81,23 @@ class ModuleWaitPong : public Module
        {
                if(command == "PONG")
                {
+                       ServerInstance->Log(DEBUG,"PONG command");
                        char* pingrpl;
                        user->GetExt(extenstr, pingrpl);
                        
                        if(pingrpl)
                        {
+                               ServerInstance->Log(DEBUG,"PONG command - has extend");
                                if(strcmp(pingrpl, parameters[0]) == 0)
                                {
+                                       ServerInstance->Log(DEBUG,"PONG command - pong matches ping ");
                                        DELETE(pingrpl);
                                        user->Shrink(extenstr);
                                        return 1;
                                }
                                else
                                {
+                                       ServerInstance->Log(DEBUG,"PONG command - pong doesnt match ping");
                                        if(killonbadreply)
                                                userrec::QuitUser(ServerInstance, user, "Incorrect ping reply for registration");
                                        return 1;
@@ -101,11 +105,13 @@ class ModuleWaitPong : public Module
                        }
                }
                
+               ServerInstance->Log(DEBUG,"PONG command - fall through");
                return 0;
        }
 
        virtual bool OnCheckReady(userrec* user)
        {
+               ServerInstance->Log(DEBUG,"PONG command - oncheckready");
                char* pingrpl;
                return (!user->GetExt(extenstr, pingrpl));
        }