X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fctables.h;h=9376dbbcc4df88a2a4761079b27ad541dec90369;hb=7f7ffef3b4d5dc6242918a48713d6fab96928a80;hp=a69f5c86f65e14c3fc18ae7abdd75b4deee4905c;hpb=f71e6bf9cb41811f18864f5d4eecb26e29d03f25;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/ctables.h b/include/ctables.h index a69f5c86f..9376dbbcc 100644 --- a/include/ctables.h +++ b/include/ctables.h @@ -23,14 +23,17 @@ #pragma once -/** Used to indicate command success codes - */ +/** Used to indicate the result of trying to execute a command. */ enum CmdResult { - CMD_FAILURE = 0, /* Command exists, but failed */ - CMD_SUCCESS = 1, /* Command exists, and succeeded */ - CMD_INVALID = 2, /* Command doesnt exist at all! */ - CMD_EPERM = 3 /* Command failed because of a permission check */ + /** The command exists but its execution failed. */ + CMD_FAILURE = 0, + + /** The command exists and its execution succeeded. */ + CMD_SUCCESS = 1, + + /* The command does not exist. */ + CMD_INVALID = 2 }; /** Flag for commands that are only allowed from servers */ @@ -163,36 +166,16 @@ class CoreExport CommandBase : public ServiceProvider * @param maxpara Maximum number of parameters this command may have - extra parameters * will be tossed into one last space-seperated param. */ - CommandBase(Module* me, const std::string &cmd, int minpara = 0, int maxpara = 0) : - ServiceProvider(me, cmd, SERVICE_COMMAND), flags_needed(0), min_params(minpara), max_params(maxpara), - use_count(0), disabled(false), works_before_reg(false), allow_empty_last_param(true), - Penalty(1) - { - } + CommandBase(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0); - virtual RouteDescriptor GetRouting(User* user, const std::vector& parameters) - { - return ROUTE_LOCALONLY; - } + virtual RouteDescriptor GetRouting(User* user, const std::vector& parameters); /** Encode a parameter for server->server transmission. * Used for parameters for which the translation type is TR_CUSTOM. * @param parameter The parameter to encode. Can be modified in place. * @param index The parameter index (0 == first parameter). */ - virtual void EncodeParameter(std::string& parameter, int index) - { - } - - /** Decode a parameter from server->server transmission. - * Not currently used in this version of InspIRCd. - * Used for parameters for which the translation type is TR_CUSTOM. - * @param parameter The parameter to decode. Can be modified in place. - * @param index The parameter index (0 == first parameter). - */ - virtual void DecodeParameter(std::string& parameter, int index) - { - } + virtual void EncodeParameter(std::string& parameter, int index); /** Disable or enable this command. * @param setting True to disable the command. @@ -229,11 +212,7 @@ class CoreExport Command : public CommandBase */ bool force_manual_route; - Command(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0) - : CommandBase(me, cmd, minpara, maxpara) - , force_manual_route(false) - { - } + Command(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0); /** Handle the command from a user. * @param parameters The parameters for the command. @@ -242,6 +221,10 @@ class CoreExport Command : public CommandBase */ virtual CmdResult Handle(const std::vector& parameters, User* user) = 0; + /** Register this object in the CommandParser + */ + void RegisterService() CXX11_OVERRIDE; + /** Destructor * Removes this command from the command parser */