153451Speter/* kwset.h - header declaring the keyword set library.
253475Sobrien   Copyright (C) 1989, 1998 Free Software Foundation, Inc.
353451Speter
453451Speter   This program is free software; you can redistribute it and/or modify
553451Speter   it under the terms of the GNU General Public License as published by
653475Sobrien   the Free Software Foundation; either version 2, or (at your option)
753451Speter   any later version.
853451Speter
953451Speter   This program is distributed in the hope that it will be useful,
1053451Speter   but WITHOUT ANY WARRANTY; without even the implied warranty of
1153451Speter   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1253451Speter   GNU General Public License for more details.
1353451Speter
1453451Speter   You should have received a copy of the GNU General Public License
1553451Speter   along with this program; if not, write to the Free Software
1653475Sobrien   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1753475Sobrien   02111-1307, USA.  */
1853451Speter
1953475Sobrien/* Written August 1989 by Mike Haertel.
2053451Speter   The author may be reached (Email) at the address mike@ai.mit.edu,
2153451Speter   or (US mail) as Mike Haertel c/o Free Software Foundation. */
2253451Speter
2353475Sobrien/* $FreeBSD$ */
2453475Sobrien
2553451Speterstruct kwsmatch
2653451Speter{
2753451Speter  int index;			/* Index number of matching keyword. */
28131557Stjr  size_t offset[1];		/* Offset of each submatch. */
2953451Speter  size_t size[1];		/* Length of each submatch. */
3053451Speter};
3153451Speter
3253475Sobrientypedef ptr_t kwset_t;
3353451Speter
3453451Speter/* Return an opaque pointer to a newly allocated keyword set, or NULL
3553451Speter   if enough memory cannot be obtained.  The argument if non-NULL
3653451Speter   specifies a table of character translations to be applied to all
3753451Speter   pattern and search text. */
38131557Stjrextern kwset_t kwsalloc PARAMS((char const *));
3953451Speter
4053451Speter/* Incrementally extend the keyword set to include the given string.
4153451Speter   Return NULL for success, or an error message.  Remember an index
4253451Speter   number for each keyword included in the set. */
43131557Stjrextern char *kwsincr PARAMS((kwset_t, char const *, size_t));
4453451Speter
4553451Speter/* When the keyword set has been completely built, prepare it for
4653451Speter   use.  Return NULL for success, or an error message. */
4753475Sobrienextern char *kwsprep PARAMS((kwset_t));
4853451Speter
4953451Speter/* Search through the given buffer for a member of the keyword set.
5053451Speter   Return a pointer to the leftmost longest match found, or NULL if
5153451Speter   no match is found.  If foundlen is non-NULL, store the length of
5253451Speter   the matching substring in the integer it points to.  Similarly,
5353451Speter   if foundindex is non-NULL, store the index of the particular
5453451Speter   keyword found therein. */
55131557Stjrextern size_t kwsexec PARAMS((kwset_t, char const *, size_t, struct kwsmatch *));
5653451Speter
5753451Speter/* Deallocate the given keyword set and all its associated storage. */
5853475Sobrienextern void kwsfree PARAMS((kwset_t));
5953451Speter
60