]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/inspircd.h
Fix my whoopsies
[user/henk/code/inspircd.git] / include / inspircd.h
index 3d9002f53e053ffc57317bdedbd70b5549f52a98..006e8092ed29021dd0199338b58120dfbe8d69ed 100644 (file)
@@ -77,6 +77,25 @@ template<typename T> inline long ConvToInt(const T &in)
        return atoi(tmp.str().c_str());
 }
 
+/** Template function to convert integer to char, storing result in *res and
+ * also returning the pointer to res. Based on Stuart Lowe's C/C++ Pages.
+ */
+template<typename T, typename V, typename R> inline char* itoa(const T &in, V *res, R base)
+{
+       if (base < 2 || base > 16) { *res = 0; return res; }
+       char* out = res;
+       int quotient = in;
+       while (quotient) {
+               *out = "0123456789abcdef"[ std::abs( quotient % base ) ];
+               ++out;
+               quotient /= base;
+       }
+       if ( in < 0 && base == 10) *out++ = '-';
+       std::reverse( res, out );
+       *out = 0;
+       return res;
+}
+
 /** This class contains various STATS counters
  * It is used by the InspIRCd class, which internally
  * has an instance of it.
@@ -475,6 +494,10 @@ class InspIRCd : public classbase
 
        void AddGlobalClone(userrec* user);
 
+       /** Number of users with a certain mode set on them
+        */
+       int ModeCount(const char mode);
+
        /** Get the time offset in seconds
         * @return The current time delta (in seconds)
         */