glob.h revision 158810
11539Srgrimes/*
21539Srgrimes * Copyright (c) 1989, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * This code is derived from software contributed to Berkeley by
61539Srgrimes * Guido van Rossum.
71539Srgrimes *
81539Srgrimes * Redistribution and use in source and binary forms, with or without
91539Srgrimes * modification, are permitted provided that the following conditions
101539Srgrimes * are met:
111539Srgrimes * 1. Redistributions of source code must retain the above copyright
121539Srgrimes *    notice, this list of conditions and the following disclaimer.
131539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141539Srgrimes *    notice, this list of conditions and the following disclaimer in the
151539Srgrimes *    documentation and/or other materials provided with the distribution.
161539Srgrimes * 3. All advertising materials mentioning features or use of this software
171539Srgrimes *    must display the following acknowledgement:
181539Srgrimes *	This product includes software developed by the University of
191539Srgrimes *	California, Berkeley and its contributors.
201539Srgrimes * 4. Neither the name of the University nor the names of its contributors
211539Srgrimes *    may be used to endorse or promote products derived from this software
221539Srgrimes *    without specific prior written permission.
231539Srgrimes *
241539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341539Srgrimes * SUCH DAMAGE.
351539Srgrimes *
361539Srgrimes *	@(#)glob.h	8.1 (Berkeley) 6/2/93
3774469Sjlemon * $FreeBSD: head/include/glob.h 158810 2006-05-22 05:39:57Z ache $
381539Srgrimes */
391539Srgrimes
401539Srgrimes#ifndef _GLOB_H_
411539Srgrimes#define	_GLOB_H_
421539Srgrimes
431539Srgrimes#include <sys/cdefs.h>
441539Srgrimes
451539Srgrimesstruct stat;
461539Srgrimestypedef struct {
47158808Sache	size_t gl_pathc;	/* Count of total paths so far. */
48158810Sache	size_t gl_matchc;	/* Count of paths matching pattern. */
49158810Sache	size_t gl_offs;		/* Reserved at beginning of gl_pathv. */
501539Srgrimes	int gl_flags;		/* Copy of flags parameter to glob. */
511539Srgrimes	char **gl_pathv;	/* List of paths matching pattern. */
521539Srgrimes				/* Copy of errfunc parameter to glob. */
5393032Simp	int (*gl_errfunc)(const char *, int);
541539Srgrimes
551539Srgrimes	/*
561539Srgrimes	 * Alternate filesystem access methods for glob; replacement
571539Srgrimes	 * versions of closedir(3), readdir(3), opendir(3), stat(2)
581539Srgrimes	 * and lstat(2).
591539Srgrimes	 */
6093032Simp	void (*gl_closedir)(void *);
6193032Simp	struct dirent *(*gl_readdir)(void *);
6293032Simp	void *(*gl_opendir)(const char *);
6393032Simp	int (*gl_lstat)(const char *, struct stat *);
6493032Simp	int (*gl_stat)(const char *, struct stat *);
651539Srgrimes} glob_t;
661539Srgrimes
67100217Smikeh#if __POSIX_VISIBLE >= 199209
68100217Smikeh/* Believed to have been introduced in 1003.2-1992 */
691539Srgrimes#define	GLOB_APPEND	0x0001	/* Append to output from previous call. */
701539Srgrimes#define	GLOB_DOOFFS	0x0002	/* Use gl_offs. */
711539Srgrimes#define	GLOB_ERR	0x0004	/* Return on error. */
721539Srgrimes#define	GLOB_MARK	0x0008	/* Append / to matching directories. */
731539Srgrimes#define	GLOB_NOCHECK	0x0010	/* Return pattern itself if nothing matches. */
741539Srgrimes#define	GLOB_NOSORT	0x0020	/* Don't sort. */
75100217Smikeh#define	GLOB_NOESCAPE	0x2000	/* Disable backslash escaping. */
761539Srgrimes
77100217Smikeh/* Error values returned by glob(3) */
78100217Smikeh#define	GLOB_NOSPACE	(-1)	/* Malloc call failed. */
79100217Smikeh#define	GLOB_ABORTED	(-2)	/* Unignored error. */
80100217Smikeh#define	GLOB_NOMATCH	(-3)	/* No match and GLOB_NOCHECK was not set. */
81100217Smikeh#define	GLOB_NOSYS	(-4)	/* Obsolete: source comptability only. */
82100217Smikeh#endif /* __POSIX_VISIBLE >= 199209 */
83100217Smikeh
84100217Smikeh#if __BSD_VISIBLE
851539Srgrimes#define	GLOB_ALTDIRFUNC	0x0040	/* Use alternately specified directory funcs. */
861539Srgrimes#define	GLOB_BRACE	0x0080	/* Expand braces ala csh. */
871539Srgrimes#define	GLOB_MAGCHAR	0x0100	/* Pattern had globbing characters. */
881539Srgrimes#define	GLOB_NOMAGIC	0x0200	/* GLOB_NOCHECK without magic chars (csh). */
891539Srgrimes#define	GLOB_QUOTE	0x0400	/* Quote special chars with \. */
901539Srgrimes#define	GLOB_TILDE	0x0800	/* Expand tilde names from the passwd file. */
9180525Smikeh#define	GLOB_LIMIT	0x1000	/* limit number of returned paths */
921539Srgrimes
93100217Smikeh/* source compatibility, these are the old names */
9480525Smikeh#define GLOB_MAXPATH	GLOB_LIMIT
95100217Smikeh#define	GLOB_ABEND	GLOB_ABORTED
96100217Smikeh#endif /* __BSD_VISIBLE */
9780525Smikeh
981539Srgrimes__BEGIN_DECLS
9993032Simpint	glob(const char *, int, int (*)(const char *, int), glob_t *);
10093032Simpvoid	globfree(glob_t *);
1011539Srgrimes__END_DECLS
1021539Srgrimes
1031539Srgrimes#endif /* !_GLOB_H_ */
104