home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / GUSI / Examples / GUSITest_P.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-11  |  868 b   |  28 lines  |  [TEXT/MPS ]

  1. /*********************************************************************
  2. File        :    GUSI                -    Grand Unified Socket Interface
  3. File        :    GUSITest_P.h    -    Common testing gear
  4. Author    :    Matthias Neeracher <neeri@iis.ethz.ch>
  5. Started    :    25Jul92                                Language    :    MPW C
  6. Last        :    25Jul92
  7. *********************************************************************/
  8.  
  9. #include <CType.h>
  10.  
  11. #define NROFCHARS                26
  12. #define DECODE(ch)            ((ch) ? (ch) - (isupper(ch) ? 'A' : 'a') + 1 : 0)
  13. #define CMDCODE(ch1,ch2)    (DECODE(ch1)*(NROFCHARS+1)+DECODE(ch2))
  14. #define NROFCMDS                (NROFCHARS+1)*(NROFCHARS+1)
  15.  
  16. typedef struct {
  17.     TestCmd            proc;
  18.     const char *    syntax;
  19.     const char *    help;
  20. } CmdDef;
  21.  
  22. extern CmdDef commands[NROFCMDS];
  23.  
  24. #define DISPATCH(ch1,ch2)    commands[CMDCODE(ch1,ch2)].proc
  25. #define USAGE(ch1,ch2)         commands[CMDCODE(ch1,ch2)].syntax
  26. #define HELPMSG(ch1,ch2)     commands[CMDCODE(ch1,ch2)].help
  27.  
  28.