From a753fb1bc711e10794e939e424f3cdd703116d82 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 2 Apr 2004 12:38:41 +0000 Subject: Added support for modules to create commands - this needs a proof-of-concept module yet, do not use unless you like to live dangerously. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@351 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/modules.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/modules.h b/include/modules.h index d9d04e762..b26554d56 100644 --- a/include/modules.h +++ b/include/modules.h @@ -20,6 +20,7 @@ #include "dynamic.h" #include "base.h" +#include "ctables.h" #include #include @@ -34,6 +35,8 @@ typedef file_cache string_list; #define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]-> +extern void createcommand(char* cmd, handlerfunc f, char flags, int minparams); + // class Version holds the version information of a Module, returned // by Module::GetVersion (thanks RD) @@ -271,6 +274,22 @@ class Server : public classbase * effects. */ virtual bool AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off); + + /** Adds a command to the command table. + * This allows modules to add extra commands into the command table. You must place a function within your + * module which is is of type handlerfunc: + * + * typedef void (handlerfunc) (char**, int, userrec*); + * ... + * void handle_kill(char **parameters, int pcnt, userrec *user) + * + * When the command is typed, the parameters will be placed into the parameters array (similar to argv) and + * the parameter count will be placed into pcnt (similar to argv). There will never be any less parameters + * than the 'minparams' value you specified when creating the command. The *user parameter is the class of + * the user which caused the command to trigger, who will always have the flag you specified in 'flags' when + * creating the initial command. For example to create an oper only command create the commands with flags='o'. + */ + virtual void AddCommand(char* cmd, handlerfunc f, char flags, int minparams); }; -- cgit v1.2.3