1/* kwset.h - header declaring the keyword set library. 2 Copyright (C) 1989, 1998, 2005 Free Software Foundation, Inc. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2, or (at your option) 7 any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software Foundation, 16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 17 18/* Written August 1989 by Mike Haertel. 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#include <stddef.h> 23 24struct kwsmatch 25{ 26 int index; /* Index number of matching keyword. */ 27 size_t offset[1]; /* Offset of each submatch. */ 28 size_t size[1]; /* Length of each submatch. */ 29}; 30 31typedef struct kwset * 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. */ 37extern kwset_t kwsalloc (char const *); 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. */ 42extern const char *kwsincr (kwset_t, char const *, 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. */ 46extern const 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. */ 54extern size_t kwsexec (kwset_t, char const *, size_t, struct kwsmatch *); 55 56/* Deallocate the given keyword set and all its associated storage. */ 57extern void kwsfree (kwset_t); 58 59