Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / gnu / usr.bin / grep / kwset.h
1 /* kwset.h - header declaring the keyword set library.
2    Copyright (C) 1989, 1998 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
16    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17    02111-1307, USA.  */
18
19 /* Written August 1989 by Mike Haertel.
20    The author may be reached (Email) at the address mike@ai.mit.edu,
21    or (US mail) as Mike Haertel c/o Free Software Foundation. */
22
23 /* $FreeBSD: src/gnu/usr.bin/grep/kwset.h,v 1.4 1999/11/20 23:42:43 obrien Exp $ */
24 /* $DragonFly: src/gnu/usr.bin/grep/kwset.h,v 1.2 2003/06/17 04:25:45 dillon Exp $ */
25
26 struct kwsmatch
27 {
28   int index;                    /* Index number of matching keyword. */
29   char *beg[1];                 /* Begin pointer for each submatch. */
30   size_t size[1];               /* Length of each submatch. */
31 };
32
33 typedef ptr_t kwset_t;
34
35 /* Return an opaque pointer to a newly allocated keyword set, or NULL
36    if enough memory cannot be obtained.  The argument if non-NULL
37    specifies a table of character translations to be applied to all
38    pattern and search text. */
39 extern kwset_t kwsalloc PARAMS((char *));
40
41 /* Incrementally extend the keyword set to include the given string.
42    Return NULL for success, or an error message.  Remember an index
43    number for each keyword included in the set. */
44 extern char *kwsincr PARAMS((kwset_t, char *, size_t));
45
46 /* When the keyword set has been completely built, prepare it for
47    use.  Return NULL for success, or an error message. */
48 extern char *kwsprep PARAMS((kwset_t));
49
50 /* Search through the given buffer for a member of the keyword set.
51    Return a pointer to the leftmost longest match found, or NULL if
52    no match is found.  If foundlen is non-NULL, store the length of
53    the matching substring in the integer it points to.  Similarly,
54    if foundindex is non-NULL, store the index of the particular
55    keyword found therein. */
56 extern char *kwsexec PARAMS((kwset_t, char *, size_t, struct kwsmatch *));
57
58 /* Deallocate the given keyword set and all its associated storage. */
59 extern void kwsfree PARAMS((kwset_t));
60