X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fcommand_parse.h;h=e8240fcf9bf1a57a501947ab39a46e79ae3d6795;hb=f3624af468d769f0cb05cf17cd18111f5faa9ec3;hp=a0d27be174e9d514ff488dcf0a96ed56e06bebd5;hpb=13aeb82ad2462d3eb2952365fd944c8837d55ea8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/command_parse.h b/include/command_parse.h index a0d27be17..e8240fcf9 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -2,12 +2,9 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * - * + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits * - * Written by Craig Edwards, Craig McLure, and others. * This program is free but copyrighted software; see * the file COPYING for details. * @@ -22,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. @@ -31,13 +32,17 @@ 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 */ InspIRCd* ServerInstance; + /** Parameter buffer + */ + std::vector para; + /** Process a parameter string into a list of items * @param command_p The output list of items * @param parameters The input string @@ -71,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* */ @@ -96,9 +107,19 @@ class CommandParser : public classbase * @param parameters Parameter list as an array of array of char (that's not a typo). * @param pcnt The number of items in the parameters list * @param user The user to call the handler on behalf of - * @return This method will return true if the command handler was found and called + * @return This method will return CMD_SUCCESS if the command handler was found and called, + * and the command completeld successfully. It will return CMD_FAILURE if the command handler was found + * and called, but the command did not complete successfully, and it will return CMD_INVALID if the + * command simply did not exist at all or the wrong number of parameters were given, or the user + * was not privilaged enough to execute the command. */ - bool CallHandler(const std::string &commandname,const char** parameters, int pcnt, userrec *user); + 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. * @param commandname The command name to check @@ -189,9 +210,35 @@ class cmd_reload : public command_t cmd_reload (InspIRCd* Instance) : command_t(Instance,"RELOAD",'o',1) { syntax = ""; } /** Handle RELOAD */ - void Handle(const char** parameters, int pcnt, userrec *user); + 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 +