home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / internet / tcpip / src205 / TCPIP_Src / Main / h / ncmdparse
Encoding:
Text File  |  1995-02-27  |  1.7 KB  |  50 lines

  1. #ifndef _cmdparse_h
  2. #define _cmdparse_h
  3.  
  4. #include "vterm.h"
  5.  
  6. /* Command Parse completion codes
  7.  */
  8. #define CMD_OK        0 /* Command accepted, and executed */
  9. #define CMD_FAIL      1 /* Generical command fail during exec code */
  10. #define CMD_HELP      2 /* Help requested about command */
  11. #define CMD_SYNTAX    3 /* Syntax report needed */
  12. #define CMD_UNKNOWN   4 /* Unknown commond */
  13. #define CMD_PARSEERR  5 /* Missing quote, bad escape sequence etc */
  14.  
  15. typedef int (*cmd_proc)(int /*argc */, char** /* *argv[] */);
  16.  
  17. typedef struct cmdtab_str* cmdtab;
  18.  
  19. typedef struct cmdtab_str {
  20.   char *command;              /* Command name */
  21.   cmd_proc proc;              /* Execution function */
  22.   int minargs;                /* Min number acceptable args */
  23.   char *syntax;               /* Standard syntax message */
  24.   char *fail;                 /* Generic fail message */
  25. } cmdtab_str;
  26.  
  27. /* Examine a strings for flags. The presence of flags
  28.    is indicated by the 1st char being a '-'.
  29.  
  30.    If it is a flags string, for each character in the flags
  31.    string, set a or clear a bit in the flag word according
  32.    the the position of the char in the flags list string.
  33.    Prefixing any flag with '!' or '~' clears the flag.
  34.  */
  35. unsigned int command_flags(unsigned int opts, char *flags, char *flist);
  36.  
  37. /* Takes a command, tokenises it and passes it to command_parse */
  38. int command_parse(cmdtab table, char *cmd, vterm vt);
  39.  
  40. /* Look up command in command list and execute it, or give help etc */
  41. int command_process(cmdtab table, int argc, char* argv[], vterm vt);
  42.  
  43. /*
  44.  * Split a string into tokens, or count tokens
  45.  * Warning: this butchers line
  46.  */
  47. int command_tokenise(char *line, char *argv[]);
  48.  
  49. #endif
  50.