xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/libgrep/libgrep.h (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1 /* Search for patterns in strings or files.
2    Copyright (C) 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 #ifndef _LIBGREP_H
19 #define _LIBGREP_H
20 
21 #include <stdbool.h>
22 #include <stddef.h>
23 
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /* A pattern matcher.  */
31 typedef struct {
32 
33   /* Compile a pattern and return the compiled pattern.  */
34   void * (*compile) (const char *pattern, size_t pattern_size,
35 		     bool match_icase, bool match_words, bool match_lines,
36 		     char eolbyte);
37 
38   /* Execute a search.  */
39   size_t (*execute) (const void *compiled_pattern,
40 		     const char *buf, size_t buf_size,
41 		     size_t *match_size, bool exact);
42 
43   /* Free a compiled pattern.  */
44   void (*free) (void *compiled_pattern);
45 
46 } matcher_t;
47 
48 /* The built-in pattern matchers.  */
49 extern matcher_t matcher_grep;   /* POSIX Basic Regular Expressions */
50 extern matcher_t matcher_egrep;  /* POSIX Extended Regular Expressions */
51 extern matcher_t matcher_fgrep;  /* Fixed String search */
52 extern matcher_t matcher_awk;    /* AWK Regular Expressions */
53 
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 
60 #endif /* _LIBGREP_H */
61