xref: /dflybsd-src/contrib/grep/lib/exclude.h (revision 91b9ed38d3db6a8a8ac5b66da1d43e6e331e259a)
195b7b453SJohn Marino /* exclude.h -- declarations for excluding file names
295b7b453SJohn Marino 
3*09d4459fSDaniel Fojt    Copyright (C) 1992-1994, 1997, 1999, 2001-2003, 2005-2006, 2009-2020 Free
4200fbe8dSJohn Marino    Software Foundation, Inc.
595b7b453SJohn Marino 
695b7b453SJohn Marino    This program is free software: you can redistribute it and/or modify
795b7b453SJohn Marino    it under the terms of the GNU General Public License as published by
895b7b453SJohn Marino    the Free Software Foundation; either version 3 of the License, or
995b7b453SJohn Marino    (at your option) any later version.
1095b7b453SJohn Marino 
1195b7b453SJohn Marino    This program is distributed in the hope that it will be useful,
1295b7b453SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
1395b7b453SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1495b7b453SJohn Marino    GNU General Public License for more details.
1595b7b453SJohn Marino 
1695b7b453SJohn Marino    You should have received a copy of the GNU General Public License
17*09d4459fSDaniel Fojt    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
1895b7b453SJohn Marino 
1995b7b453SJohn Marino #ifndef _GL_EXCLUDE_H
2095b7b453SJohn Marino #define _GL_EXCLUDE_H 1
2195b7b453SJohn Marino 
2295b7b453SJohn Marino #include <stdbool.h>
23680a9cb8SJohn Marino #include <stdio.h>
2495b7b453SJohn Marino 
2595b7b453SJohn Marino /* Written by Paul Eggert <eggert@twinsun.com>
2695b7b453SJohn Marino    and Sergey Poznyakoff <gray@gnu.org> */
2795b7b453SJohn Marino 
2895b7b453SJohn Marino /* Exclude options, which can be ORed with fnmatch options.  */
2995b7b453SJohn Marino 
3095b7b453SJohn Marino /* Patterns must match the start of file names, instead of matching
3195b7b453SJohn Marino    anywhere after a '/'.  */
3295b7b453SJohn Marino #define EXCLUDE_ANCHORED (1 << 30)
3395b7b453SJohn Marino 
3495b7b453SJohn Marino /* Include instead of exclude.  */
3595b7b453SJohn Marino #define EXCLUDE_INCLUDE (1 << 29)
3695b7b453SJohn Marino 
3795b7b453SJohn Marino /* '?', '*', '[', and '\\' are special in patterns.  Without this
3895b7b453SJohn Marino    option, these characters are ordinary and fnmatch is not used.  */
3995b7b453SJohn Marino #define EXCLUDE_WILDCARDS (1 << 28)
4095b7b453SJohn Marino 
41680a9cb8SJohn Marino /* Patterns are POSIX extended regular expressions */
42680a9cb8SJohn Marino #define EXCLUDE_REGEX     (1 << 27)
43680a9cb8SJohn Marino 
44680a9cb8SJohn Marino /* Allocate storage for the pattern */
45680a9cb8SJohn Marino #define EXCLUDE_ALLOC     (1 << 26)
46680a9cb8SJohn Marino 
4795b7b453SJohn Marino struct exclude;
4895b7b453SJohn Marino 
49cf28ed85SJohn Marino bool fnmatch_pattern_has_wildcards (const char *, int) _GL_ATTRIBUTE_PURE;
5095b7b453SJohn Marino 
51*09d4459fSDaniel Fojt struct exclude *new_exclude (void) _GL_ATTRIBUTE_MALLOC;
5295b7b453SJohn Marino void free_exclude (struct exclude *);
5395b7b453SJohn Marino void add_exclude (struct exclude *, char const *, int);
5495b7b453SJohn Marino int add_exclude_file (void (*) (struct exclude *, char const *, int),
5595b7b453SJohn Marino                       struct exclude *, char const *, int, char);
56680a9cb8SJohn Marino int add_exclude_fp (void (*) (struct exclude *, char const *, int, void *),
57680a9cb8SJohn Marino                     struct exclude *, FILE *, int, char, void *);
5895b7b453SJohn Marino bool excluded_file_name (struct exclude const *, char const *);
59680a9cb8SJohn Marino void exclude_add_pattern_buffer (struct exclude *ex, char *buf);
60680a9cb8SJohn Marino bool exclude_fnmatch (char const *, char const *, int);
6195b7b453SJohn Marino 
6295b7b453SJohn Marino #endif /* _GL_EXCLUDE_H */
63