X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fcommand_parse.h;h=2c883be203b696458ea4c6366af404c907161355;hb=e6d000042ea75d4e0485bec9564b47163a3ca414;hp=cbcbea2d8382b205eaeeefcb6add4e9bf877e85a;hpb=4381bb63f57d7a542827f2481e8198313e4ff24a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/command_parse.h b/include/command_parse.h index cbcbea2d8..2c883be20 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. @@ -52,10 +56,6 @@ class CoreExport CommandParser : public classbase */ void ProcessCommand(userrec *user, std::string &cmd); - /** Insert the default RFC1459 commands into the command hash. - */ - void SetupCommandTable(); - /** Finds the init_command symbol in a .so file * @param v A function pointer to be initialized * @param h A valid shared object handle @@ -69,8 +69,9 @@ class CoreExport CommandParser : public classbase /** Load a command from a shared object on disk. * @param name The shared object to load (without path) + * @return NULL on success, pointer to dlerrr() error message on failure */ - void LoadCommand(const char* name); + const char* 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). @@ -91,7 +92,7 @@ class CoreExport CommandParser : public classbase * @return True if the command was reloaded, false if it could not be found * or another error occured */ - bool ReloadCommand(const char* cmd); + bool ReloadCommand(const char* cmd, userrec* user); /** Default constructor. * @param Instance The creator of this class @@ -111,6 +112,10 @@ class CoreExport 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. @@ -189,6 +194,21 @@ class CoreExport CommandParser : public classbase * @return True if the command was added */ bool CreateCommand(command_t *f, void* so_handle = NULL); + + /** Insert the default RFC1459 commands into the command hash. + * Ignore any already loaded commands. + * @param user User to spool errors to, or if NULL, when an error occurs spool the errors to + * stdout then exit with EXIT_STATUS_HANDLER. + */ + void SetupCommandTable(userrec* user); + + /** Translate nicknames in a string into UIDs, based on the TranslationType given. + * @param to The translation type to use for the process. + * @param source The input string + * @param dest The output string, it is safe to pass source and dest as the same variable only for translation type TR_TEXT. + * @return returns the number of substitutions made. Will always be 0 or 1 for TR_TEXT and 0..n for other types. + */ + int TranslateUIDs(TranslateType to, const std::string &source, std::string &dest); }; /** Command handler class for the RELOAD command.