xref: /minix3/include/glob.h (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras /*	$NetBSD: glob.h,v 1.26 2010/09/06 14:38:56 christos Exp $	*/
2*2fe8fb19SBen Gras 
339aa2e64SBen Gras /*
439aa2e64SBen Gras  * Copyright (c) 1989, 1993
539aa2e64SBen Gras  *	The Regents of the University of California.  All rights reserved.
639aa2e64SBen Gras  *
739aa2e64SBen Gras  * This code is derived from software contributed to Berkeley by
839aa2e64SBen Gras  * Guido van Rossum.
939aa2e64SBen Gras  *
1039aa2e64SBen Gras  * Redistribution and use in source and binary forms, with or without
1139aa2e64SBen Gras  * modification, are permitted provided that the following conditions
1239aa2e64SBen Gras  * are met:
1339aa2e64SBen Gras  * 1. Redistributions of source code must retain the above copyright
1439aa2e64SBen Gras  *    notice, this list of conditions and the following disclaimer.
1539aa2e64SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
1639aa2e64SBen Gras  *    notice, this list of conditions and the following disclaimer in the
1739aa2e64SBen Gras  *    documentation and/or other materials provided with the distribution.
1839aa2e64SBen Gras  * 3. Neither the name of the University nor the names of its contributors
1939aa2e64SBen Gras  *    may be used to endorse or promote products derived from this software
2039aa2e64SBen Gras  *    without specific prior written permission.
2139aa2e64SBen Gras  *
2239aa2e64SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2339aa2e64SBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2439aa2e64SBen Gras  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2539aa2e64SBen Gras  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2639aa2e64SBen Gras  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2739aa2e64SBen Gras  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2839aa2e64SBen Gras  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2939aa2e64SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3039aa2e64SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3139aa2e64SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3239aa2e64SBen Gras  * SUCH DAMAGE.
3339aa2e64SBen Gras  *
3439aa2e64SBen Gras  *	@(#)glob.h	8.1 (Berkeley) 6/2/93
3539aa2e64SBen Gras  */
3639aa2e64SBen Gras 
3739aa2e64SBen Gras #ifndef _GLOB_H_
3839aa2e64SBen Gras #define	_GLOB_H_
3939aa2e64SBen Gras 
40*2fe8fb19SBen Gras #include <sys/cdefs.h>
41*2fe8fb19SBen Gras #include <sys/featuretest.h>
42*2fe8fb19SBen Gras #include <sys/types.h>
43*2fe8fb19SBen Gras #include <sys/stat.h>
44*2fe8fb19SBen Gras 
45*2fe8fb19SBen Gras #ifndef __gl_size_t
46*2fe8fb19SBen Gras #define __gl_size_t	size_t
47*2fe8fb19SBen Gras #endif
48*2fe8fb19SBen Gras #ifndef __gl_stat_t
49*2fe8fb19SBen Gras #define __gl_stat_t	struct stat
50*2fe8fb19SBen Gras #endif
51*2fe8fb19SBen Gras 
5239aa2e64SBen Gras typedef struct {
53*2fe8fb19SBen Gras 	__gl_size_t gl_pathc;	/* Count of total paths so far. */
54*2fe8fb19SBen Gras 	__gl_size_t gl_matchc;	/* Count of paths matching pattern. */
55*2fe8fb19SBen Gras 	__gl_size_t gl_offs;	/* Reserved at beginning of gl_pathv. */
5639aa2e64SBen Gras 	int gl_flags;		/* Copy of flags parameter to glob. */
5739aa2e64SBen Gras 	char **gl_pathv;	/* List of paths matching pattern. */
5839aa2e64SBen Gras 				/* Copy of errfunc parameter to glob. */
5939aa2e64SBen Gras 	int (*gl_errfunc)(const char *, int);
6039aa2e64SBen Gras 
6139aa2e64SBen Gras 	/*
6239aa2e64SBen Gras 	 * Alternate filesystem access methods for glob; replacement
6339aa2e64SBen Gras 	 * versions of closedir(3), readdir(3), opendir(3), stat(2)
6439aa2e64SBen Gras 	 * and lstat(2).
6539aa2e64SBen Gras 	 */
6639aa2e64SBen Gras 	void (*gl_closedir)(void *);
6739aa2e64SBen Gras 	struct dirent *(*gl_readdir)(void *);
6839aa2e64SBen Gras 	void *(*gl_opendir)(const char *);
69*2fe8fb19SBen Gras 	int (*gl_lstat)(const char *, __gl_stat_t *);
70*2fe8fb19SBen Gras 	int (*gl_stat)(const char *, __gl_stat_t *);
7139aa2e64SBen Gras } glob_t;
7239aa2e64SBen Gras 
7339aa2e64SBen Gras #define	GLOB_APPEND	0x0001	/* Append to output from previous call. */
7439aa2e64SBen Gras #define	GLOB_DOOFFS	0x0002	/* Use gl_offs. */
7539aa2e64SBen Gras #define	GLOB_ERR	0x0004	/* Return on error. */
7639aa2e64SBen Gras #define	GLOB_MARK	0x0008	/* Append / to matching directories. */
7739aa2e64SBen Gras #define	GLOB_NOCHECK	0x0010	/* Return pattern itself if nothing matches. */
7839aa2e64SBen Gras #define	GLOB_NOSORT	0x0020	/* Don't sort. */
7939aa2e64SBen Gras #define	GLOB_NOESCAPE	0x1000	/* Disable backslash escaping. */
8039aa2e64SBen Gras 
8139aa2e64SBen Gras #define	GLOB_NOSPACE	(-1)	/* Malloc call failed. */
8239aa2e64SBen Gras #define	GLOB_ABORTED	(-2)	/* Unignored error. */
83*2fe8fb19SBen Gras #define	GLOB_NOMATCH	(-3)	/* No match, and GLOB_NOCHECK was not set. */
84*2fe8fb19SBen Gras #define	GLOB_NOSYS	(-4)	/* Implementation does not support function. */
8539aa2e64SBen Gras 
86*2fe8fb19SBen Gras #if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H)
8739aa2e64SBen Gras #define	GLOB_ALTDIRFUNC	0x0040	/* Use alternately specified directory funcs. */
8839aa2e64SBen Gras #define	GLOB_BRACE	0x0080	/* Expand braces ala csh. */
8939aa2e64SBen Gras #define	GLOB_MAGCHAR	0x0100	/* Pattern had globbing characters. */
9039aa2e64SBen Gras #define	GLOB_NOMAGIC	0x0200	/* GLOB_NOCHECK without magic chars (csh). */
91*2fe8fb19SBen Gras #define	GLOB_LIMIT	0x0400	/* Limit memory used by matches to ARG_MAX */
9239aa2e64SBen Gras #define	GLOB_TILDE	0x0800	/* Expand tilde names from the passwd file. */
93*2fe8fb19SBen Gras /*	GLOB_NOESCAPE	0x1000	above */
94*2fe8fb19SBen Gras #define	GLOB_PERIOD	0x2000	/* Allow metachars to match leading periods. */
95*2fe8fb19SBen Gras #define	GLOB_NO_DOTDIRS	0x4000	/* Make . and .. vanish from wildcards. */
96*2fe8fb19SBen Gras #define	GLOB_STAR	0x8000	/* Use glob ** to recurse directories */
97*2fe8fb19SBen Gras #define	GLOB_QUOTE	0	/* source compatibility */
9839aa2e64SBen Gras 
99*2fe8fb19SBen Gras #define	GLOB_ABEND	GLOB_ABORTED	/* source compatibility */
100*2fe8fb19SBen Gras #endif
10139aa2e64SBen Gras 
102*2fe8fb19SBen Gras __BEGIN_DECLS
103*2fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
104*2fe8fb19SBen Gras int	glob(const char * __restrict, int,
105*2fe8fb19SBen Gras     int (*)(const char *, int), glob_t * __restrict)	 __RENAME(__glob30);
106*2fe8fb19SBen Gras void	globfree(glob_t *)				 __RENAME(__globfree30);
107*2fe8fb19SBen Gras #endif
108*2fe8fb19SBen Gras #ifdef _NETBSD_SOURCE
109*2fe8fb19SBen Gras int	glob_pattern_p(const char *, int);
110*2fe8fb19SBen Gras #endif
111*2fe8fb19SBen Gras __END_DECLS
11239aa2e64SBen Gras 
11339aa2e64SBen Gras #endif /* !_GLOB_H_ */
114