home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pine / ccmd / cmfncs.top < prev    next >
Encoding:
Text File  |  1988-08-19  |  5.4 KB  |  146 lines

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