home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BDSC / BDSC-3 / PAT.H < prev    next >
C/C++ Source or Header  |  2000-06-30  |  2KB  |  67 lines

  1. /*        Pattern Search Defines & Globals
  2.  *
  3.  *    This file contains defines, macros, and global declarations for
  4.  * a simple pattern searcher.  See pat.c for more details.
  5.  *
  6.  *
  7.  *    Initial coding 8/18/82 by Harry R. Chesley.
  8.  *
  9.  *
  10.  *    Copyright 1982 by Harry R. Chesley.
  11.  *    Unlimited permission granted for non-profit use only.
  12.  */
  13.  
  14. /* DEBUG - if defined, turn on various debugging print-outs.
  15.  *
  16.  * SETMAX - size of sets (128 elements (one per possible char)/16 elements
  17.  *        per word = 8 words).
  18.  * PATMAX - maximum size of pattern.
  19.  *
  20.  * TRUE, FALSE - logical values.
  21.  */
  22.  
  23. /*#define DEBUG*/
  24.  
  25. #define SETMAX 8
  26. #define PATMAX 100
  27.  
  28. #define TRUE 1
  29. #define FALSE 0
  30.  
  31. struct pel {            /* Pattern "elements". */
  32.     int pel_type;        /* Type of element (see below). */
  33.     char pel_c;        /* Character for match-one elements. */
  34.     unsigned pel_set[SETMAX]; /* Set for match-set elements. */
  35. };
  36.  
  37. /* Values for pel_type above:
  38.  *
  39.  *    MONEC - match exactly one of set_c.
  40.  *    MONEA - match exactly one of any character (except EOL).
  41.  *    MMANY - match one for more of anything (except EOL).
  42.  *    MSET - match any character in set.
  43.  */
  44.  
  45. #define MONEC 0
  46. #define MONEA 1
  47. #define MMANY 2
  48. #define MSET 3
  49.  
  50. /* Operations on sets:
  51.  *
  52.  *    inset(sptr,mem) - returns TRUE if mem is in set, FALSE otherwise.
  53.  */
  54.  
  55. #define inset(s,m) (s->pel_set[(m>>4)&7] & (1<<(m&15)))
  56.  
  57. /* Globals:
  58.  */
  59.  
  60. struct pel cpat[PATMAX];    /* The compiled search pattern. */
  61.  
  62. struct pel *cptop;        /* Pointer to last element in pattern. */
  63.  
  64. char eolch;            /* End-of-line character. */
  65.  
  66. char *nextstr;            /* First char past matched string. */
  67.