00001 #ifndef __CMDHANDLER_H 00002 #define __CMDHANDLER_H 00003 00004 struct CommandHandler; 00005 00006 struct CommandHandler *newCommandHandler(void); 00007 void freeCommandHandler(struct CommandHandler *ch); 00008 00009 /* Call this when you accept a new client */ 00010 void newClientStarted(struct CommandHandler *ch, int cliIndex); 00011 00012 /* Pass in command string and function pointer */ 00013 void enregisterCommand(struct CommandHandler *ch, const char *cmd, void (*func)(struct CommandHandler *ch, int cliIndex)); 00014 00015 /* Handles characters using the command handler state machine */ 00016 void handleLine(struct CommandHandler *ch, const char *line, int cliIndex); 00017 00018 /* Gets the integer parameters associated with the last line parsed */ 00019 /* This will skip the command name itself. Fetches num of them */ 00020 /* Returns results in val. Returns 0 to indicate success */ 00021 int fetchIntParameters(struct CommandHandler *ch, int *vals, int num); 00022 00023 /* Gets just the command name */ 00024 const char *fetchCommandName(struct CommandHandler *ch); 00025 00026 /* Gets a single string parameter */ 00027 const char *fetchStringParameter(struct CommandHandler *ch, int which); 00028 00029 #endif