Update Gnulib to the latest git version
[deliverable/binutils-gdb.git] / gnulib / import / glob-libc.h
CommitLineData
c0c3707f 1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
6ec2e0f5
SDJ
2 This file is part of the GNU C Library.
3
c0c3707f
CB
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
6ec2e0f5 8
c0c3707f 9 The GNU C Library is distributed in the hope that it will be useful,
6ec2e0f5 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
c0c3707f
CB
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
6ec2e0f5 13
c0c3707f
CB
14 You should have received a copy of the GNU General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
6ec2e0f5
SDJ
17
18#ifndef _GLOB_H
19#define _GLOB_H 1
20
21#ifndef __GLOB_GNULIB
22# include <sys/cdefs.h>
23#endif
24
6ec2e0f5
SDJ
25__BEGIN_DECLS
26
c0c3707f
CB
27#define __need_size_t
28#include <stddef.h>
6ec2e0f5
SDJ
29
30/* Bits set in the FLAGS argument to 'glob'. */
31#define GLOB_ERR (1 << 0)/* Return on read errors. */
32#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
33#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
34#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
35#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
36#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
37#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
38#define GLOB_PERIOD (1 << 7)/* Leading '.' can be matched by metachars. */
39
c0c3707f 40#if !defined __USE_POSIX2 || defined __USE_MISC
6ec2e0f5
SDJ
41# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
42# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
43# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
44# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
45# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
46# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
47# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
48 if the user name is not available. */
49# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
50 GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
51 GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
52 GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
53#else
54# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
55 GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
56 GLOB_PERIOD)
57#endif
58
59/* Error returns from 'glob'. */
60#define GLOB_NOSPACE 1 /* Ran out of memory. */
61#define GLOB_ABORTED 2 /* Read error. */
62#define GLOB_NOMATCH 3 /* No matches found. */
63#define GLOB_NOSYS 4 /* Not implemented. */
64#ifdef __USE_GNU
65/* Previous versions of this file defined GLOB_ABEND instead of
66 GLOB_ABORTED. Provide a compatibility definition here. */
67# define GLOB_ABEND GLOB_ABORTED
68#endif
69
70/* Structure describing a globbing run. */
71#ifdef __USE_GNU
72struct stat;
73#endif
74typedef struct
75 {
c0c3707f 76 size_t gl_pathc; /* Count of paths matched by the pattern. */
6ec2e0f5 77 char **gl_pathv; /* List of matched pathnames. */
c0c3707f 78 size_t gl_offs; /* Slots to reserve in 'gl_pathv'. */
6ec2e0f5
SDJ
79 int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
80
81 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
82 are used instead of the normal file access functions. */
83 void (*gl_closedir) (void *);
84#ifdef __USE_GNU
85 struct dirent *(*gl_readdir) (void *);
86#else
87 void *(*gl_readdir) (void *);
88#endif
89 void *(*gl_opendir) (const char *);
90#ifdef __USE_GNU
c0c3707f
CB
91 int (*gl_lstat) (const char *__restrict, struct stat *__restrict);
92 int (*gl_stat) (const char *__restrict, struct stat *__restrict);
6ec2e0f5 93#else
c0c3707f
CB
94 int (*gl_lstat) (const char *__restrict, void *__restrict);
95 int (*gl_stat) (const char *__restrict, void *__restrict);
6ec2e0f5
SDJ
96#endif
97 } glob_t;
98
c0c3707f 99#ifdef __USE_LARGEFILE64
6ec2e0f5
SDJ
100# ifdef __USE_GNU
101struct stat64;
102# endif
103typedef struct
104 {
c0c3707f 105 size_t gl_pathc;
6ec2e0f5 106 char **gl_pathv;
c0c3707f 107 size_t gl_offs;
6ec2e0f5
SDJ
108 int gl_flags;
109
110 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
111 are used instead of the normal file access functions. */
112 void (*gl_closedir) (void *);
113# ifdef __USE_GNU
114 struct dirent64 *(*gl_readdir) (void *);
115# else
116 void *(*gl_readdir) (void *);
117# endif
118 void *(*gl_opendir) (const char *);
119# ifdef __USE_GNU
c0c3707f
CB
120 int (*gl_lstat) (const char *__restrict, struct stat64 *__restrict);
121 int (*gl_stat) (const char *__restrict, struct stat64 *__restrict);
6ec2e0f5 122# else
c0c3707f
CB
123 int (*gl_lstat) (const char *__restrict, void *__restrict);
124 int (*gl_stat) (const char *__restrict, void *__restrict);
6ec2e0f5
SDJ
125# endif
126 } glob64_t;
127#endif
128
6ec2e0f5
SDJ
129/* Do glob searching for PATTERN, placing results in PGLOB.
130 The bits defined above may be set in FLAGS.
131 If a directory cannot be opened or read and ERRFUNC is not nil,
132 it is called with the pathname that caused the error, and the
133 'errno' value from the failing call; if it returns non-zero
134 'glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
135 If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
136 Otherwise, 'glob' returns zero. */
c0c3707f
CB
137#if !defined __USE_FILE_OFFSET64 || defined __GLOB_GNULIB
138extern int glob (const char *__restrict __pattern, int __flags,
6ec2e0f5 139 int (*__errfunc) (const char *, int),
c0c3707f 140 glob_t *__restrict __pglob) __THROW;
6ec2e0f5
SDJ
141
142/* Free storage allocated in PGLOB by a previous 'glob' call. */
c0c3707f 143extern void globfree (glob_t *__pglob) __THROW;
6ec2e0f5 144#else
c0c3707f 145extern int __REDIRECT_NTH (glob, (const char *__restrict __pattern,
6ec2e0f5
SDJ
146 int __flags,
147 int (*__errfunc) (const char *, int),
c0c3707f 148 glob_t *__restrict __pglob), glob64);
6ec2e0f5
SDJ
149
150extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
151#endif
152
c0c3707f
CB
153#ifdef __USE_LARGEFILE64
154extern int glob64 (const char *__restrict __pattern, int __flags,
6ec2e0f5 155 int (*__errfunc) (const char *, int),
c0c3707f 156 glob64_t *__restrict __pglob) __THROW;
6ec2e0f5 157
c0c3707f 158extern void globfree64 (glob64_t *__pglob) __THROW;
6ec2e0f5
SDJ
159#endif
160
161
162#ifdef __USE_GNU
163/* Return nonzero if PATTERN contains any metacharacters.
164 Metacharacters can be quoted with backslashes if QUOTE is nonzero.
165
166 This function is not part of the interface specified by POSIX.2
167 but several programs want to use it. */
c0c3707f 168extern int glob_pattern_p (const char *__pattern, int __quote) __THROW;
6ec2e0f5
SDJ
169#endif
170
171__END_DECLS
172
173#endif /* glob.h */
This page took 0.200888 seconds and 4 git commands to generate.