Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / grep / src / kwset.h
blob30c0acf03c95fa3b326f34e0cf306e721f00b5d4
1 /* $NetBSD$ */
3 /* kwset.h - header declaring the keyword set library.
4 Copyright (C) 1989, 1998 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
21 /* Written August 1989 by Mike Haertel.
22 The author may be reached (Email) at the address mike@ai.mit.edu,
23 or (US mail) as Mike Haertel c/o Free Software Foundation. */
25 struct kwsmatch
27 int index; /* Index number of matching keyword. */
28 size_t offset[1]; /* Offset of each submatch. */
29 size_t size[1]; /* Length of each submatch. */
32 typedef ptr_t kwset_t;
34 /* Return an opaque pointer to a newly allocated keyword set, or NULL
35 if enough memory cannot be obtained. The argument if non-NULL
36 specifies a table of character translations to be applied to all
37 pattern and search text. */
38 extern kwset_t kwsalloc PARAMS((char const *));
40 /* Incrementally extend the keyword set to include the given string.
41 Return NULL for success, or an error message. Remember an index
42 number for each keyword included in the set. */
43 extern char *kwsincr PARAMS((kwset_t, char const *, size_t));
45 /* When the keyword set has been completely built, prepare it for
46 use. Return NULL for success, or an error message. */
47 extern char *kwsprep PARAMS((kwset_t));
49 /* Search through the given buffer for a member of the keyword set.
50 Return a pointer to the leftmost longest match found, or NULL if
51 no match is found. If foundlen is non-NULL, store the length of
52 the matching substring in the integer it points to. Similarly,
53 if foundindex is non-NULL, store the index of the particular
54 keyword found therein. */
55 extern size_t kwsexec PARAMS((kwset_t, char const *, size_t, struct kwsmatch *));
57 /* Deallocate the given keyword set and all its associated storage. */
58 extern void kwsfree PARAMS((kwset_t));