X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fcommand_parse.h;h=e8240fcf9bf1a57a501947ab39a46e79ae3d6795;hb=f3624af468d769f0cb05cf17cd18111f5faa9ec3;hp=98e189f9ace9aa1ad9184e1ef73f842116273d3b;hpb=696ee9ff66bb94be2229bfa9c3dc288affc38a72;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/command_parse.h b/include/command_parse.h index 98e189f9a..e8240fcf9 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -19,8 +19,12 @@ #include "ctables.h" #include "typedefs.h" +/** Required forward declaration + */ class InspIRCd; +/** A list of dll/so files containing the command handlers for the core + */ typedef std::map SharedObjectList; /** This class handles command management and parsing. @@ -28,7 +32,7 @@ typedef std::map SharedObjectList; * call command handlers by name, and chop up comma seperated * parameters into multiple calls. */ -class CommandParser : public classbase +class CoreExport CommandParser : public classbase { private: /** The creator of this class @@ -72,6 +76,12 @@ class CommandParser : public classbase */ void LoadCommand(const char* name); + /** Removes a command if the sources match. Used as a helper for + * safe hash_map delete while iter in RemoveCommands(const char* source). + */ + void RemoveCommand(nspace::hash_map::iterator safei, const char* source); + + public: /** Command list, a hash_map of command names to command_t* */ @@ -105,6 +115,10 @@ class CommandParser : public classbase */ CmdResult CallHandler(const std::string &commandname,const char** parameters, int pcnt, userrec *user); + /** Get the handler function for a command. + * @param commandname The command required. Always use uppercase for this parameter. + * @return a pointer to the command handler, or NULL + */ command_t* GetHandler(const std::string &commandname); /** This function returns true if a command is valid with the given number of parameters and user. @@ -199,6 +213,32 @@ class cmd_reload : public command_t CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; - +/** A lookup table of values for multiplier characters used by + * InspIRCd::Duration(). In this lookup table, the indexes for + * the ascii values 'm' and 'M' have the value '60', the indexes + * for the ascii values 'D' and 'd' have a value of '86400', etc. + */ +const int duration_multi[] = +{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 86400, 1, 1, 1, 3600, + 1, 1, 1, 1, 60, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 604800, 1, 31536000, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 86400, 1, 1, 1, 3600, 1, 1, 1, 1, 60, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 604800, 1, 31536000, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; #endif +