diff options
-rw-r--r-- | include/helperfuncs.h | 2 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 23 | ||||
-rw-r--r-- | src/modules/m_sslmodes.cpp | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/include/helperfuncs.h b/include/helperfuncs.h index d2fa40e20..ddfdf2826 100644 --- a/include/helperfuncs.h +++ b/include/helperfuncs.h @@ -84,4 +84,6 @@ bool AllModulesReportReady(userrec* user); bool DirValid(char* dirandfile); std::string GetFullProgDir(char** argv, int argc); +int InsertMode(std::string &output, const char* modes, unsigned short section); + #endif diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 767cb7caa..2923041fc 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -1373,3 +1373,26 @@ std::string GetFullProgDir(char** argv, int argc) return otherdir; } +int InsertMode(std::string &output, const char* mode, unsigned short section) +{ + unsigned short currsection = 1; + unsigned int pos = output.find("CHANMODES=", 0) + 10; // +10 for the length of "CHANMODES=" + + if(section > 4 || section == 0) + { + log(DEBUG, "InsertMode: CHANMODES doesn't have a section %dh :/", section); + return 0; + } + + for(; pos < output.size(); pos++) + { + if(section == currsection) + break; + + if(output[pos] == ',') + currsection++; + } + + output.insert(pos, mode); + return 1; +} diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp index 1a7f0670b..3ed40108d 100644 --- a/src/modules/m_sslmodes.cpp +++ b/src/modules/m_sslmodes.cpp @@ -24,7 +24,7 @@ class ModuleSSLModes : public Module virtual void On005Numeric(std::string &output) { - output.insert(output.find(" ", output.find("CHANMODES=", 0)), "z"); + InsertMode(output, "z", 4); } virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) |