]> git.ipfire.org Git - thirdparty/bash.git/blame - pathexp.h
Bash-4.4 patch 4
[thirdparty/bash.git] / pathexp.h
CommitLineData
ccc6cda3
JA
1/* pathexp.h -- The shell interface to the globbing library. */
2
a0c0a00f 3/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
ccc6cda3
JA
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
3185942a
JA
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.
ccc6cda3 11
3185942a
JA
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.
ccc6cda3 16
3185942a
JA
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*/
ccc6cda3
JA
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
28extern int noglob_dot_filenames;
29extern char *glob_error_return;
30#endif /* !USE_POSIX_GLOB_LIBRARY */
31
cce855bc
JA
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 */
f1be666c 35#define QGLOB_REGEXP 0x04 /* quote an ERE for regcomp/regexec */
cce855bc
JA
36
37#if defined (EXTENDED_GLOB)
f73dda09 38/* Flags to OR with other flag args to strmatch() to enabled the extended
cce855bc
JA
39 pattern matching. */
40# define FNMATCH_EXTFLAG (extended_glob ? FNM_EXTMATCH : 0)
41#else
42# define FNMATCH_EXTFLAG 0
43#endif /* !EXTENDED_GLOB */
44
95732b49 45#define FNMATCH_IGNCASE (match_ignore_case ? FNM_CASEFOLD : 0)
a0c0a00f 46#define FNMATCH_NOCASEGLOB (glob_ignore_case ? FNM_CASEFOLD : 0)
95732b49 47
ccc6cda3 48extern int glob_dot_filenames;
cce855bc 49extern int extended_glob;
3185942a 50extern int glob_star;
95732b49 51extern int match_ignore_case; /* doesn't really belong here */
ccc6cda3
JA
52
53extern int unquoted_glob_pattern_p __P((char *));
54
cce855bc 55/* PATHNAME can contain characters prefixed by CTLESC; this indicates
ccc6cda3 56 that the character is to be quoted. We quote it here in the style
cce855bc 57 that the glob library recognizes. If flags includes QGLOB_CVTNULL,
ccc6cda3
JA
58 we change quoted null strings (pathname[0] == CTLNUL) into empty
59 strings (pathname[0] == 0). If this is called after quote removal
cce855bc 60 is performed, (flags & QGLOB_CVTNULL) should be 0; if called when quote
ccc6cda3 61 removal has not been done (for example, before attempting to match a
cce855bc
JA
62 pattern while executing a case statement), flags should include
63 QGLOB_CVTNULL. If flags includes QGLOB_FILENAME, appropriate quoting
64 to match a filename should be performed. */
28ef6c31 65extern char *quote_string_for_globbing __P((const char *, int));
ccc6cda3 66
3185942a 67extern int glob_char_p __P((const char *));
a0c0a00f 68extern char *quote_globbing_chars __P((const char *));
ccc6cda3
JA
69
70/* Call the glob library to do globbing on PATHNAME. */
28ef6c31 71extern char **shell_glob_filename __P((const char *));
ccc6cda3 72
f73dda09 73/* Filename completion ignore. Used to implement the "fignore" facility of
a0c0a00f 74 tcsh, GLOBIGNORE (like ksh-93 FIGNORE), and EXECIGNORE.
ccc6cda3
JA
75
76 It is passed a NULL-terminated array of (char *)'s that must be
77 free()'d if they are deleted. The first element (names[0]) is the
78 least-common-denominator string of the matching patterns (i.e.
79 u<TAB> produces names[0] = "und", names[1] = "under.c", names[2] =
80 "undun.c", name[3] = NULL). */
81
82struct ign {
83 char *val;
84 int len, flags;
85};
86
f73dda09
JA
87typedef int sh_iv_item_func_t __P((struct ign *));
88
ccc6cda3 89struct ignorevar {
a0c0a00f 90 char *varname; /* FIGNORE, GLOBIGNORE, or EXECIGNORE */
ccc6cda3
JA
91 struct ign *ignores; /* Store the ignore strings here */
92 int num_ignores; /* How many are there? */
93 char *last_ignoreval; /* Last value of variable - cached for speed */
f73dda09 94 sh_iv_item_func_t *item_func; /* Called when each item is parsed from $`varname' */
ccc6cda3
JA
95};
96
97extern void setup_ignore_patterns __P((struct ignorevar *));
98
99extern void setup_glob_ignore __P((char *));
100extern int should_ignore_glob_matches __P((void));
101extern void ignore_glob_matches __P((char **));
102
103#endif