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 3 of the License, or 7 (at your option) 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, see <https://www.gnu.org/licenses/>. */ 16 17 #ifndef _LIBGREP_H 18 #define _LIBGREP_H 19 20 #include <stdbool.h> 21 #include <stddef.h> 22 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 29 /* A pattern matcher. */ 30 typedef struct { 31 32 /* Compile a pattern and return the compiled pattern. */ 33 void * (*compile) (const char *pattern, size_t pattern_size, 34 bool match_icase, bool match_words, bool match_lines, 35 char eolbyte); 36 37 /* Execute a search. */ 38 size_t (*execute) (const void *compiled_pattern, 39 const char *buf, size_t buf_size, 40 size_t *match_size, bool exact); 41 42 /* Free a compiled pattern. */ 43 void (*free) (void *compiled_pattern); 44 45 } matcher_t; 46 47 /* The built-in pattern matchers. */ 48 extern matcher_t matcher_grep; /* POSIX Basic Regular Expressions */ 49 extern matcher_t matcher_egrep; /* POSIX Extended Regular Expressions */ 50 extern matcher_t matcher_fgrep; /* Fixed String search */ 51 extern matcher_t matcher_awk; /* AWK Regular Expressions */ 52 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 59 #endif /* _LIBGREP_H */ 60