X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/13eb55ea375a8f15f6d867809459df3ab897e423..f4c9742568a27f565ebc2902491ef64038da20da:/parser/parser.h diff --git a/parser/parser.h b/parser/parser.h index 1aa03054..870a9bf8 100644 --- a/parser/parser.h +++ b/parser/parser.h @@ -30,14 +30,16 @@ */ typedef int (*CommandHandler)(void *, int, char**); +typedef void (*DestroyExt)(void *); typedef struct Command { sstring *command; /* Name of the command/token/thing */ - char *help; /* Help information, sorry splidge! */ int level; /* "level" required to use the command/token/thing */ int maxparams; /* Maximum number of parameters for the command/token/thing */ CommandHandler handler; /* Function to deal with the message */ void *ext; /* Pointer to some arbitrary other data */ + DestroyExt destroyext; /* Function to destroy ->ext on destroycommandtree (if necessary) */ + unsigned int calls; /* How many times this command has been called */ struct Command *next; /* Next handler chained onto this command */ } Command; @@ -49,11 +51,12 @@ typedef struct CommandTree { CommandTree *newcommandtree(); void destroycommandtree(CommandTree *ct); -Command *addcommandhelptotree(CommandTree *ct, const char *cmdname, int level, int maxparams, CommandHandler handler, const char *help); +Command *addcommandexttotree(CommandTree *ct, const char *cmdname, int level, int maxparams, CommandHandler handler, void *ext); int deletecommandfromtree(CommandTree *ct, const char *cmdname, CommandHandler handler); Command *findcommandintree(CommandTree *ct, const char *cmdname, int strictcheck); int getcommandlist(CommandTree *ct, Command **commandlist, int maxcommands); +sstring *getcommandname(CommandTree *ct, CommandHandler handler); -#define addcommandtotree(a, b, c, d, e) addcommandhelptotree(a, b, c, d, e, NULL) +#define addcommandtotree(a, b, c, d, e) addcommandexttotree(a, b, c, d, e, NULL) #endif