home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / grep20.zip / kwset.h < prev    next >
C/C++ Source or Header  |  1992-06-27  |  3KB  |  70 lines

  1. /* kwset.h - header declaring the keyword set library.
  2.    Copyright 1989 Free Software Foundation
  3.           Written August 1989 by Mike Haertel.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 1, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.    The author may be reached (Email) at the address mike@ai.mit.edu,
  20.    or (US mail) as Mike Haertel c/o Free Software Foundation. */
  21.  
  22. struct kwsmatch
  23. {
  24.   int index;            /* Index number of matching keyword. */
  25.   char *beg[1];            /* Begin pointer for each submatch. */
  26.   size_t size[1];        /* Length of each submatch. */
  27. };
  28.  
  29. #if __STDC__
  30.  
  31. typedef void *kwset_t;
  32.  
  33. /* Return an opaque pointer to a newly allocated keyword set, or NULL
  34.    if enough memory cannot be obtained.  The argument if non-NULL
  35.    specifies a table of character translations to be applied to all
  36.    pattern and search text. */
  37. extern kwset_t kwsalloc(char *);
  38.  
  39. /* Incrementally extend the keyword set to include the given string.
  40.    Return NULL for success, or an error message.  Remember an index
  41.    number for each keyword included in the set. */
  42. extern char *kwsincr(kwset_t, char *, size_t);
  43.  
  44. /* When the keyword set has been completely built, prepare it for
  45.    use.  Return NULL for success, or an error message. */
  46. extern char *kwsprep(kwset_t);
  47.  
  48. /* Search through the given buffer for a member of the keyword set.
  49.    Return a pointer to the leftmost longest match found, or NULL if
  50.    no match is found.  If foundlen is non-NULL, store the length of
  51.    the matching substring in the integer it points to.  Similarly,
  52.    if foundindex is non-NULL, store the index of the particular
  53.    keyword found therein. */
  54. extern char *kwsexec(kwset_t, char *, size_t, struct kwsmatch *);
  55.  
  56. /* Deallocate the given keyword set and all its associated storage. */
  57. extern void kwsfree(kwset_t);
  58.  
  59. #else
  60.  
  61. typedef char *kwset_t;
  62.  
  63. extern kwset_t kwsalloc();
  64. extern char *kwsincr();
  65. extern char *kwsprep();
  66. extern char *kwsexec();
  67. extern void kwsfree();
  68.  
  69. #endif
  70.