]> jfr.im git - irc/quakenet/newserv.git/blobdiff - parser/parser.h
fix indentation
[irc/quakenet/newserv.git] / parser / parser.h
index bce50aa30cf01aa1045b8535c861169dc2e18fb9..794d968699de0d9f622b96c631ca15fcf2ddc288 100644 (file)
@@ -21,6 +21,7 @@
 #define CMD_OK              0
 #define CMD_ERROR           1
 #define CMD_LAST            2
+#define CMD_USAGE           3
 
 /* Generic CommandHandler type
  * void * = pointer to some relevant object to identify where the message came from
@@ -29,6 +30,7 @@
  */
 
 typedef int (*CommandHandler)(void *, int, char**);
+typedef void (*DestroyExt)(void *); 
  
 typedef struct Command {
   sstring        *command;       /* Name of the command/token/thing */
@@ -36,6 +38,7 @@ typedef struct Command {
   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) */
   struct Command *next;          /* Next handler chained onto this command */
 } Command;
   
@@ -47,9 +50,12 @@ typedef struct CommandTree {
 
 CommandTree *newcommandtree();
 void destroycommandtree(CommandTree *ct);
-Command *addcommandtotree(CommandTree *ct, const char *cmdname, int level, int maxparams, CommandHandler handler);
+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) addcommandexttotree(a, b, c, d, e, NULL)
 
 #endif