home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mm / ccmd / cmfncs.top < prev    next >
Encoding:
Text File  |  1990-12-18  |  5.3 KB  |  145 lines

  1. /*
  2.  Copyright (c) 1986, 1990 by The Trustees of Columbia University in
  3.  the City of New York.  Permission is granted to any individual or
  4.  institution to use, copy, or redistribute this software so long as it
  5.  is not sold for profit, provided this copyright notice is retained.
  6.  
  7.  Author: Andrew Lowry
  8. */
  9. /* Internal symbols, declarations, and storage allocations required by
  10. ** the system modules of the ccmd package.  This file is generated
  11. ** automatically by m4 from information in cmfnc.h4 and the various
  12. ** cm???.cnf configuration files.  The initial portion of this file,
  13. ** including this comment, is copied verbatim from the file cmfnc.top.
  14. */
  15.  
  16. /*
  17. ** The ftspec structure contains information for parsing a particular
  18. ** field type, including pointers to three handler functions, and a pointer
  19. ** to a default break table.  The parsing handler is invoked when an
  20. ** attempt is made to parse the current input using this field type.
  21. ** The help handler is invoked to provide a standard help message for
  22. ** this field.  The completion handler is invoked when the user has
  23. ** requested completion for this field type.  Calling conventions are as
  24. ** follows:
  25. **
  26. ** _ftprs (parse handler):
  27. **   Input arguments:
  28. **      text - A pointer to the text to be parsed.
  29. **      textlen - The number of characters in the text.
  30. **      fdbp - A pointer to the FDB that caused this handler to be invoked.
  31. **
  32. **   Output arguments:
  33. **     parselen - The number of characters consumed by a successful parse.
  34. **     value - A pointer to a data item to be filled with the result of
  35. **       a successful parse.  (The data item is not allocated by the
  36. **       parse handler -- the passed pointer must point to an existing 
  37. **     item.)
  38. **
  39. **   Returns: Standard return code.
  40. **
  41. ** _fthlp (help handler):
  42. **   Input arguments:
  43. **      text - A pointer to the text being parsed.
  44. **      textlen - The number of characters in text.
  45. **      fdbp - A pointer to the FDB that caused this handler to be invoked.
  46. **      cust - TRUE if a custom help string was typed for this FDB
  47. **
  48. **   Output arguments: None.
  49. **
  50. **   Returns: Standard return code.
  51. **
  52. ** _ftcmp (completion handler):
  53. **   Input arguments:
  54. **     text - A pointer to the text being parsed.
  55. **     textlen - The number of characters in text.
  56. **     fdbp - A pointer to the FDB that caused this handler to be invoked.
  57. **     full - TRUE if full completion is requested, otherwise only partial
  58. **       completion is required.
  59. **
  60. **   Output arguments:
  61. **     cplt - A pointer to the completion text to be filled in.  NULL
  62. **       means no completion text.
  63. **     cpltlen - If cplt is not NULL, the number of characters to fill
  64. **       in.  -1 means fill in to the end of the completion string
  65. **       (zero terminated).
  66. **
  67. **   Returns: Flags (defined below) whether or not to:
  68. **     - Beep at the user (flag CMP_BEL)
  69. **     - Add a space after the completion text (flag CMP_SPC)
  70. **     - Stop completion after first punctuation char (flag CMP_PNC)
  71. **     - Wake up the parse (flag CMP_GO)
  72. **/
  73.  
  74. typedef struct FTSPEC {
  75.   int (*_ftprs)();        /* parse handler address */
  76.   int (*_fthlp)();        /* help handler address */
  77.   int (*_ftcmp)();        /* completion handler address */
  78.   int _ftflg;            /* field type flags */
  79.   brktab *_ftbrk;        /* standard break table */
  80. } ftspec;
  81.   
  82. /* Flags defined for ftspec structure (_ftflg field) */
  83.  
  84. #define    FT_DFX    0x0001        /* blocks defaulting on confirm */
  85.  
  86. /* Flags to be returned by completion handlers */
  87.  
  88. #define CMP_BEL    0x0001        /* beep at the user */
  89. #define CMP_SPC    0x0002        /* add space after completion text */
  90. #define CMP_GO    0x0004        /* wakeup requested */
  91. #define CMP_PNC    0x0008        /* end completion after first punctuation */
  92.  
  93. /* global break table shared by some parse functions */
  94.  
  95. extern brktab cmallbk;
  96.  
  97. /* Error table, indexed by the left byte of an error code,
  98. ** points to a function error structure, which includes a count
  99. ** of the number of error codes in the table, and a pointer to
  100. ** an array of error strings, indexed by the right byte of the
  101. ** error code.
  102. **/
  103.  
  104. typedef struct FNERR {
  105.   int _fecnt;            /* number of error strings in table */
  106.   char **_ferrs;        /* pointer to array of error strings */
  107. } fnerr;
  108.  
  109. /* badfnc - Macro to decide whether a given function code is legal.
  110. ** First, the code is checked for a range error.  If it passes, the
  111. ** function table entry is checked for a NULL parse function pointer,
  112. ** indicating that the function has been stubbed out of this application.
  113. **/
  114.  
  115. #define badfnc(code)    (((code) < 1) || ((code) > cmfmax) ? TRUE : \
  116.              (cmfntb[(code)-1]->_ftprs == NULL))
  117.  
  118. /* Some useful character constants */
  119.  
  120. #define NULCHAR    '\0'
  121. #define    BELL    '\007'
  122. #define BS    '\010'
  123. #define    TAB    '\t'        /* ASCII 011 */
  124. #define    NEWLINE    '\n'        /* ASCII 012 */
  125. #define FORMFEED '\014'
  126. #define    RETURN    '\r'        /* ASCII 015 */
  127. #define SPACE    '\040'
  128. #define DELETE    '\177'
  129.  
  130. /*
  131.  * Macros to inspect break tables:
  132.  *  BREAK1(b,c) => nonzero iff character c is a 1st character break in
  133.  *    break table *b.
  134.  *  BREAKR(b,c) => nonzero iff character c is a non-1st character break in
  135.  *    break table *b.
  136.  *  BREAK(b,c,p) => nonzero iff character c is a break character in position
  137.  *    p according to break table *b.  (p should be 0 to check for 1st char
  138.  *    break, nonzero otherwise.)
  139.  */
  140.  
  141. #define    BREAK1(b,c)    (0x80 & ((b)->_br1st[(c)/8] << ((c) % 8)))
  142. #define    BREAKR(b,c)    (0x80 & ((b)->_brrest[(c)/8] << ((c) % 8)))
  143. #define BREAK(b,c,p)    ((p) == 0 ? BREAK1(b,c) : BREAKR(b,c))
  144.  
  145.