]> git.ipfire.org Git - thirdparty/bash.git/blob - pathexp.h
Bash-5.2 patch 26: fix typo when specifying readline's custom color prefix
[thirdparty/bash.git] / pathexp.h
1 /* pathexp.h -- The shell interface to the globbing library. */
2
3 /* Copyright (C) 1987-2015 Free Software Foundation, Inc.
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 Bash is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #if !defined (_PATHEXP_H_)
22 #define _PATHEXP_H_
23
24 #if defined (USE_POSIX_GLOB_LIBRARY)
25 # define GLOB_FAILED(glist) !(glist)
26 #else /* !USE_POSIX_GLOB_LIBRARY */
27 # define GLOB_FAILED(glist) (glist) == (char **)&glob_error_return
28 extern int noglob_dot_filenames;
29 extern char *glob_error_return;
30 #endif /* !USE_POSIX_GLOB_LIBRARY */
31
32 /* Flag values for quote_string_for_globbing */
33 #define QGLOB_CVTNULL 0x01 /* convert QUOTED_NULL strings to '\0' */
34 #define QGLOB_FILENAME 0x02 /* do correct quoting for matching filenames */
35 #define QGLOB_REGEXP 0x04 /* quote an ERE for regcomp/regexec */
36 #define QGLOB_CTLESC 0x08 /* turn CTLESC CTLESC into CTLESC for BREs */
37 #define QGLOB_DEQUOTE 0x10 /* like dequote_string but quote glob chars */
38
39 #if defined (EXTENDED_GLOB)
40 /* Flags to OR with other flag args to strmatch() to enabled the extended
41 pattern matching. */
42 # define FNMATCH_EXTFLAG (extended_glob ? FNM_EXTMATCH : 0)
43 #else
44 # define FNMATCH_EXTFLAG 0
45 #endif /* !EXTENDED_GLOB */
46
47 #define FNMATCH_IGNCASE (match_ignore_case ? FNM_CASEFOLD : 0)
48 #define FNMATCH_NOCASEGLOB (glob_ignore_case ? FNM_CASEFOLD : 0)
49
50 extern int glob_dot_filenames;
51 extern int extended_glob;
52 extern int glob_star;
53 extern int match_ignore_case; /* doesn't really belong here */
54
55 extern int unquoted_glob_pattern_p __P((char *));
56
57 /* PATHNAME can contain characters prefixed by CTLESC; this indicates
58 that the character is to be quoted. We quote it here in the style
59 that the glob library recognizes. If flags includes QGLOB_CVTNULL,
60 we change quoted null strings (pathname[0] == CTLNUL) into empty
61 strings (pathname[0] == 0). If this is called after quote removal
62 is performed, (flags & QGLOB_CVTNULL) should be 0; if called when quote
63 removal has not been done (for example, before attempting to match a
64 pattern while executing a case statement), flags should include
65 QGLOB_CVTNULL. If flags includes QGLOB_FILENAME, appropriate quoting
66 to match a filename should be performed. */
67 extern char *quote_string_for_globbing __P((const char *, int));
68
69 extern int glob_char_p __P((const char *));
70 extern char *quote_globbing_chars __P((const char *));
71
72 /* Call the glob library to do globbing on PATHNAME. */
73 extern char **shell_glob_filename __P((const char *));
74
75 /* Filename completion ignore. Used to implement the "fignore" facility of
76 tcsh, GLOBIGNORE (like ksh-93 FIGNORE), and EXECIGNORE.
77
78 It is passed a NULL-terminated array of (char *)'s that must be
79 free()'d if they are deleted. The first element (names[0]) is the
80 least-common-denominator string of the matching patterns (i.e.
81 u<TAB> produces names[0] = "und", names[1] = "under.c", names[2] =
82 "undun.c", name[3] = NULL). */
83
84 struct ign {
85 char *val;
86 int len, flags;
87 };
88
89 typedef int sh_iv_item_func_t __P((struct ign *));
90
91 struct ignorevar {
92 char *varname; /* FIGNORE, GLOBIGNORE, or EXECIGNORE */
93 struct ign *ignores; /* Store the ignore strings here */
94 int num_ignores; /* How many are there? */
95 char *last_ignoreval; /* Last value of variable - cached for speed */
96 sh_iv_item_func_t *item_func; /* Called when each item is parsed from $`varname' */
97 };
98
99 extern void setup_ignore_patterns __P((struct ignorevar *));
100
101 extern void setup_glob_ignore __P((char *));
102 extern int should_ignore_glob_matches __P((void));
103 extern void ignore_glob_matches __P((char **));
104
105 #endif