X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Finspircd.h;h=5e9bed45dea9afd4b490a8ab979d239e95a19f07;hb=525b7e3409884946cde5ddd6b0e8180e668032a3;hp=6cb5c0dd044b4972f45e0df54a6496f5a542ec3b;hpb=371daf9928def23164b49b39ced1d3cdeb9225b8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/inspircd.h b/include/inspircd.h index 6cb5c0dd0..5e9bed45d 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -26,14 +26,14 @@ #include "command_parse.h" #include "snomasks.h" -/** Returned by some functions to indicate failure, - * and the exit code of the program if it terminates. +/** Returned by some functions to indicate failure. */ #define ERROR -1 -/** Crucial defines +/** Support for librodent - + * see http://www.chatspike.net/index.php?z=64 */ -#define ETIREDGERBILS EAGAIN +#define ETIREDHAMSTERS EAGAIN /** Debug levels for use with InspIRCd::Log() */ @@ -62,9 +62,50 @@ template 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 inline std::string ConvToStr(const T &in) +template 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 inline std::string ConvToStr(const int in) +{ + return ConvNumeric(in); +} + +template inline std::string ConvToStr(const long in) +{ + return ConvNumeric(in); +} + +template inline std::string ConvToStr(const unsigned long in) +{ + return ConvNumeric(in); +} + +template inline std::string ConvToStr(const char* in) +{ + return in; +} + +template inline std::string ConvToStr(const long in) +{ + return (in ? "1" : "0"); +} + +template inline std::string ConvToStr(const T &in) { std::stringstream tmp; if (!(tmp << in)) return std::string(); @@ -78,6 +119,25 @@ template 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 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. @@ -367,6 +427,12 @@ class InspIRCd : public classbase int time_delta; public: + + /** Number of unregistered users online right now. + * (Unregistered means before USER/NICK/dns) + */ + int unregistered_count; + /** List of server names we've seen. */ servernamelist servernames; @@ -402,11 +468,11 @@ class InspIRCd : public classbase /** Client list, a hash_map containing all clients, local and remote */ - user_hash clientlist; + user_hash* clientlist; /** Channel list, a hash_map containing all channels */ - chan_hash chanlist; + chan_hash* chanlist; /** Local client list, a vector containing only local clients */ @@ -420,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; @@ -476,6 +534,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) */ @@ -605,6 +667,8 @@ class InspIRCd : public classbase */ void OpenLog(char** argv, int argc); + void CloseLog(); + /** Convert a user to a pseudoclient, disconnecting the real user * @param user The user to convert * @param message The quit message to display when exiting the user @@ -655,6 +719,7 @@ class InspIRCd : public classbase /** Causes the server to exit immediately * @param The exit code to give to the operating system + * (See the ExitStatus enum for valid values) */ static void Exit(int status); @@ -861,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 @@ -1121,6 +1198,23 @@ class InspIRCd : public classbase */ void Restart(const std::string &reason); + /** Prepare the ircd for restart or shutdown. + * This function unloads all modules which can be unloaded, + * closes all open sockets, and closes the logfile. + */ + void Cleanup(); + + /** This copies the user and channel hash_maps into new hash maps. + * This frees memory used by the hash_map allocator (which it neglects + * to free, most of the time, using tons of ram) + */ + 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,