]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/inspircd.h
This is a bit better
[user/henk/code/inspircd.git] / include / inspircd.h
index 1e51043226a014f4bccb208a166afca9cdec1be5..5e9bed45dea9afd4b490a8ab979d239e95a19f07 100644 (file)
@@ -62,9 +62,50 @@ template<typename T> inline void DELETE(T* x)
        x = NULL;
 }
 
-/** Template function to convert any input type to std::string
+/** Template functions to convert any input type to std::string
  */
-template<typename T> inline std::string ConvToStr(const T &in)
+template<typename N> std::string ConvNumeric(N in)
+{
+       char res[MAXBUF];
+       char* out = res;
+       long quotient = in;
+       while (quotient) {
+               *out = "0123456789"[ std::abs( quotient % 10 ) ];
+               ++out;
+               quotient /= 10;
+       }
+       if ( in < 0)
+               *out++ = '-';
+       *out = 0;
+       return std::reverse(res,out);
+}
+
+template <int> inline std::string ConvToStr(const int in)
+{
+       return ConvNumeric(in);
+}
+
+template <long> inline std::string ConvToStr(const long in)
+{
+       return ConvNumeric(in);
+}
+
+template <unsigned long> inline std::string ConvToStr(const unsigned long in)
+{
+       return ConvNumeric(in);
+}
+
+template <const char*> inline std::string ConvToStr(const char* in)
+{
+       return in;
+}
+
+template <bool> inline std::string ConvToStr(const long in)
+{
+       return (in ? "1" : "0");
+}
+
+template <typename T> inline std::string ConvToStr(const T &in)
 {
        std::stringstream tmp;
        if (!(tmp << in)) return std::string();
@@ -445,14 +486,6 @@ class InspIRCd : public classbase
 
        clonemap global_clones;
 
-       /** Whowas container, contains a map of vectors of users tracked by WHOWAS
-        */
-       irc::whowas::whowas_users whowas;
-
-       /** Whowas container, contains a map of time_t to users tracked by WHOWAS
-        */
-       irc::whowas::whowas_users_fifo whowas_fifo;
-
        /** DNS class, provides resolver facilities to the core and modules
         */
        DNS* Res;
@@ -893,9 +926,21 @@ class InspIRCd : public classbase
 
        /** Add a dns Resolver class to this server's active set
         * @param r The resolver to add
-        * @return True if the resolver was added
-        */
-        bool AddResolver(Resolver* r);
+        * @param cached If this value is true, then the cache will
+        * be searched for the DNS result, immediately. If the value is
+        * false, then a request will be sent to the nameserver, and the
+        * result will not be immediately available. You should usually
+        * use the boolean value which you passed to the Resolver
+        * constructor, which Resolver will set appropriately depending
+        * on if cached results are available and haven't expired. It is
+        * however safe to force this value to false, forcing a remote DNS
+        * lookup, but not an update of the cache.
+        * @return True if the operation completed successfully. Note that
+        * if this method returns true, you should not attempt to access
+        * the resolver class you pass it after this call, as depending upon
+        * the request given, the object may be deleted!
+        */
+        bool AddResolver(Resolver* r, bool cached);
 
        /** Add a command to this server's command parser
         * @param f A command_t command handler object to add
@@ -1165,6 +1210,11 @@ class InspIRCd : public classbase
         */
        void RehashUsersAndChans();
 
+       /** Resets the cached max bans value on all channels.
+        * Called by rehash.
+        */
+       void ResetMaxBans();
+
        /** Begin execution of the server.
         * NOTE: this function NEVER returns. Internally,
         * after performing some initialisation routines,