xref: /netbsd-src/include/glob.h (revision 2f3bda949c3d7bde4e6efb8bf8b46dae92777034)
1*2f3bda94Schristos /*	$NetBSD: glob.h,v 1.27 2019/05/29 01:21:33 christos Exp $	*/
24d2cbfceScgd 
361f28255Scgd /*
4615e52ccScgd  * Copyright (c) 1989, 1993
5615e52ccScgd  *	The Regents of the University of California.  All rights reserved.
661f28255Scgd  *
761f28255Scgd  * This code is derived from software contributed to Berkeley by
861f28255Scgd  * Guido van Rossum.
961f28255Scgd  *
1061f28255Scgd  * Redistribution and use in source and binary forms, with or without
1161f28255Scgd  * modification, are permitted provided that the following conditions
1261f28255Scgd  * are met:
1361f28255Scgd  * 1. Redistributions of source code must retain the above copyright
1461f28255Scgd  *    notice, this list of conditions and the following disclaimer.
1561f28255Scgd  * 2. Redistributions in binary form must reproduce the above copyright
1661f28255Scgd  *    notice, this list of conditions and the following disclaimer in the
1761f28255Scgd  *    documentation and/or other materials provided with the distribution.
18039cc956Sagc  * 3. Neither the name of the University nor the names of its contributors
1961f28255Scgd  *    may be used to endorse or promote products derived from this software
2061f28255Scgd  *    without specific prior written permission.
2161f28255Scgd  *
2261f28255Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2361f28255Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2461f28255Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2561f28255Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2661f28255Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2761f28255Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2861f28255Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2961f28255Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3061f28255Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3161f28255Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3261f28255Scgd  * SUCH DAMAGE.
3361f28255Scgd  *
344d2cbfceScgd  *	@(#)glob.h	8.1 (Berkeley) 6/2/93
3561f28255Scgd  */
3661f28255Scgd 
3761f28255Scgd #ifndef _GLOB_H_
3861f28255Scgd #define	_GLOB_H_
3961f28255Scgd 
4061f28255Scgd #include <sys/cdefs.h>
419a2e6944Skleink #include <sys/featuretest.h>
42d6b51107Sfvdl #include <sys/types.h>
43d6b51107Sfvdl #include <sys/stat.h>
4461f28255Scgd 
453b6811d3Schristos #ifndef __gl_size_t
463b6811d3Schristos #define __gl_size_t	size_t
473b6811d3Schristos #endif
4866412e72Schristos #ifndef __gl_stat_t
4966412e72Schristos #define __gl_stat_t	struct stat
5066412e72Schristos #endif
5166412e72Schristos 
52d6b51107Sfvdl typedef struct {
533b6811d3Schristos 	__gl_size_t gl_pathc;	/* Count of total paths so far. */
543b6811d3Schristos 	__gl_size_t gl_matchc;	/* Count of paths matching pattern. */
553b6811d3Schristos 	__gl_size_t gl_offs;	/* Reserved at beginning of gl_pathv. */
56d6b51107Sfvdl 	int gl_flags;		/* Copy of flags parameter to glob. */
57d6b51107Sfvdl 	char **gl_pathv;	/* List of paths matching pattern. */
58d6b51107Sfvdl 				/* Copy of errfunc parameter to glob. */
5919b7469aSperry 	int (*gl_errfunc)(const char *, int);
60d6b51107Sfvdl 
61d6b51107Sfvdl 	/*
62d6b51107Sfvdl 	 * Alternate filesystem access methods for glob; replacement
63d6b51107Sfvdl 	 * versions of closedir(3), readdir(3), opendir(3), stat(2)
64d6b51107Sfvdl 	 * and lstat(2).
65d6b51107Sfvdl 	 */
6619b7469aSperry 	void (*gl_closedir)(void *);
6719b7469aSperry 	struct dirent *(*gl_readdir)(void *);
6819b7469aSperry 	void *(*gl_opendir)(const char *);
6966412e72Schristos 	int (*gl_lstat)(const char *, __gl_stat_t *);
7066412e72Schristos 	int (*gl_stat)(const char *, __gl_stat_t *);
71615e52ccScgd } glob_t;
72615e52ccScgd 
73*2f3bda94Schristos #define	GLOB_APPEND	 0x00001 /* Append to output from previous call. */
74*2f3bda94Schristos #define	GLOB_DOOFFS	 0x00002 /* Use gl_offs. */
75*2f3bda94Schristos #define	GLOB_ERR	 0x00004 /* Return on error. */
76*2f3bda94Schristos #define	GLOB_MARK	 0x00008 /* Append / to matching directories. */
77*2f3bda94Schristos #define	GLOB_NOCHECK	 0x00010 /* Return pattern itself if nothing matches. */
78*2f3bda94Schristos #define	GLOB_NOSORT	 0x00020 /* Don't sort. */
79*2f3bda94Schristos #define	GLOB_NOESCAPE	 0x01000 /* Disable backslash escaping. */
80615e52ccScgd 
8100420994Stv #define	GLOB_NOSPACE	 (-1)	 /* Malloc call failed. */
8200420994Stv #define	GLOB_ABORTED	 (-2)	 /* Unignored error. */
8300420994Stv #define	GLOB_NOMATCH	 (-3)	 /* No match, and GLOB_NOCHECK was not set. */
8400420994Stv #define	GLOB_NOSYS	 (-4)	 /* Implementation does not support function. */
8500420994Stv 
86b2f78261Sjmc #if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H)
87*2f3bda94Schristos #define	GLOB_ALTDIRFUNC	 0x00040 /* Use alternately specified directory funcs. */
88*2f3bda94Schristos #define	GLOB_BRACE	 0x00080 /* Expand braces ala csh. */
89*2f3bda94Schristos #define	GLOB_MAGCHAR	 0x00100 /* Pattern had globbing characters. */
90*2f3bda94Schristos #define	GLOB_NOMAGIC	 0x00200 /* GLOB_NOCHECK without magic chars (csh). */
91*2f3bda94Schristos #define	GLOB_LIMIT	 0x00400 /* Limit memory used by matches to ARG_MAX */
92*2f3bda94Schristos #define	GLOB_TILDE	 0x00800 /* Expand tilde names from the passwd file. */
93*2f3bda94Schristos /*	GLOB_NOESCAPE	 0x01000 above */
94*2f3bda94Schristos #define	GLOB_PERIOD	 0x02000 /* Allow metachars to match leading periods. */
95*2f3bda94Schristos #define	GLOB_NO_DOTDIRS	 0x04000 /* Make . and .. vanish from wildcards. */
96*2f3bda94Schristos #define	GLOB_STAR	 0x08000 /* Use glob ** to recurse directories */
97*2f3bda94Schristos #define	GLOB_TILDE_CHECK 0x10000 /* Expand tilde names from the passwd file. */
9800420994Stv #define	GLOB_QUOTE	 0	 /* source compatibility */
99615e52ccScgd 
10000420994Stv #define	GLOB_ABEND	GLOB_ABORTED	/* source compatibility */
10100420994Stv #endif
102615e52ccScgd 
10361f28255Scgd __BEGIN_DECLS
10466412e72Schristos #ifndef __LIBC12_SOURCE__
10519b7469aSperry int	glob(const char * __restrict, int,
1063b6811d3Schristos     int (*)(const char *, int), glob_t * __restrict)	 __RENAME(__glob30);
1073b6811d3Schristos void	globfree(glob_t *)				 __RENAME(__globfree30);
10821e1e24dSfvdl #endif
1091ef020beSchristos #ifdef _NETBSD_SOURCE
1101ef020beSchristos int	glob_pattern_p(const char *, int);
1111ef020beSchristos #endif
11261f28255Scgd __END_DECLS
11361f28255Scgd 
11461f28255Scgd #endif /* !_GLOB_H_ */
115