]> git.ipfire.org Git - thirdparty/bash.git/blame - pathexp.h
Imported from ../bash-3.2.48.tar.gz.
[thirdparty/bash.git] / pathexp.h
CommitLineData
ccc6cda3
JA
1/* pathexp.h -- The shell interface to the globbing library. */
2
f1be666c 3/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
ccc6cda3
JA
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 it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
bb70624e 19 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
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
JA
45#define FNMATCH_IGNCASE (match_ignore_case ? FNM_CASEFOLD : 0)
46
ccc6cda3 47extern int glob_dot_filenames;
cce855bc 48extern int extended_glob;
95732b49 49extern int match_ignore_case; /* doesn't really belong here */
ccc6cda3
JA
50
51extern int unquoted_glob_pattern_p __P((char *));
52
cce855bc 53/* PATHNAME can contain characters prefixed by CTLESC; this indicates
ccc6cda3 54 that the character is to be quoted. We quote it here in the style
cce855bc 55 that the glob library recognizes. If flags includes QGLOB_CVTNULL,
ccc6cda3
JA
56 we change quoted null strings (pathname[0] == CTLNUL) into empty
57 strings (pathname[0] == 0). If this is called after quote removal
cce855bc 58 is performed, (flags & QGLOB_CVTNULL) should be 0; if called when quote
ccc6cda3 59 removal has not been done (for example, before attempting to match a
cce855bc
JA
60 pattern while executing a case statement), flags should include
61 QGLOB_CVTNULL. If flags includes QGLOB_FILENAME, appropriate quoting
62 to match a filename should be performed. */
28ef6c31 63extern char *quote_string_for_globbing __P((const char *, int));
ccc6cda3
JA
64
65extern char *quote_globbing_chars __P((char *));
66
67/* Call the glob library to do globbing on PATHNAME. */
28ef6c31 68extern char **shell_glob_filename __P((const char *));
ccc6cda3 69
f73dda09 70/* Filename completion ignore. Used to implement the "fignore" facility of
ccc6cda3
JA
71 tcsh and GLOBIGNORE (like ksh-93 FIGNORE).
72
73 It is passed a NULL-terminated array of (char *)'s that must be
74 free()'d if they are deleted. The first element (names[0]) is the
75 least-common-denominator string of the matching patterns (i.e.
76 u<TAB> produces names[0] = "und", names[1] = "under.c", names[2] =
77 "undun.c", name[3] = NULL). */
78
79struct ign {
80 char *val;
81 int len, flags;
82};
83
f73dda09
JA
84typedef int sh_iv_item_func_t __P((struct ign *));
85
ccc6cda3
JA
86struct ignorevar {
87 char *varname; /* FIGNORE or GLOBIGNORE */
88 struct ign *ignores; /* Store the ignore strings here */
89 int num_ignores; /* How many are there? */
90 char *last_ignoreval; /* Last value of variable - cached for speed */
f73dda09 91 sh_iv_item_func_t *item_func; /* Called when each item is parsed from $`varname' */
ccc6cda3
JA
92};
93
94extern void setup_ignore_patterns __P((struct ignorevar *));
95
96extern void setup_glob_ignore __P((char *));
97extern int should_ignore_glob_matches __P((void));
98extern void ignore_glob_matches __P((char **));
99
100#endif