diff options
author | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-01-25 20:24:46 +0000 |
---|---|---|
committer | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-01-25 20:24:46 +0000 |
commit | 72943b2c720c1d94b145b4fa61bfb89d65d4ef9c (patch) | |
tree | 3ce7e72caf2b5c8a4ff7d8f9d58fa865f3439fd6 /src/helperfuncs.cpp | |
parent | 5938aba62fa74ebf04d07abbd49cb813e6dbf026 (diff) |
Add InsertMode function to helperfuncs.(cpp|h) for easily adding modes to the CHANMODES section of the 005 numeric
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2897 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r-- | src/helperfuncs.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
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; +} |