1331722Seadler/*
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.
16203964Simp * 3. Neither the name of the University nor the names of its contributors
171539Srgrimes *    may be used to endorse or promote products derived from this software
181539Srgrimes *    without specific prior written permission.
191539Srgrimes *
201539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
211539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
221539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
231539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
241539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
251539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
261539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
271539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
281539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
291539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
301539Srgrimes * SUCH DAMAGE.
311539Srgrimes *
321539Srgrimes *	@(#)glob.h	8.1 (Berkeley) 6/2/93
3374469Sjlemon * $FreeBSD$
341539Srgrimes */
351539Srgrimes
361539Srgrimes#ifndef _GLOB_H_
371539Srgrimes#define	_GLOB_H_
381539Srgrimes
391539Srgrimes#include <sys/cdefs.h>
40158811Sache#include <sys/_types.h>
411539Srgrimes
42158811Sache#ifndef	_SIZE_T_DECLARED
43158811Sachetypedef	__size_t	size_t;
44158811Sache#define	_SIZE_T_DECLARED
45158811Sache#endif
46158811Sache
471539Srgrimesstruct stat;
481539Srgrimestypedef struct {
49158808Sache	size_t gl_pathc;	/* Count of total paths so far. */
50158810Sache	size_t gl_matchc;	/* Count of paths matching pattern. */
51158810Sache	size_t gl_offs;		/* Reserved at beginning of gl_pathv. */
521539Srgrimes	int gl_flags;		/* Copy of flags parameter to glob. */
531539Srgrimes	char **gl_pathv;	/* List of paths matching pattern. */
541539Srgrimes				/* Copy of errfunc parameter to glob. */
5593032Simp	int (*gl_errfunc)(const char *, int);
561539Srgrimes
571539Srgrimes	/*
581539Srgrimes	 * Alternate filesystem access methods for glob; replacement
591539Srgrimes	 * versions of closedir(3), readdir(3), opendir(3), stat(2)
601539Srgrimes	 * and lstat(2).
611539Srgrimes	 */
6293032Simp	void (*gl_closedir)(void *);
6393032Simp	struct dirent *(*gl_readdir)(void *);
6493032Simp	void *(*gl_opendir)(const char *);
6593032Simp	int (*gl_lstat)(const char *, struct stat *);
6693032Simp	int (*gl_stat)(const char *, struct stat *);
671539Srgrimes} glob_t;
681539Srgrimes
69100217Smikeh#if __POSIX_VISIBLE >= 199209
70100217Smikeh/* Believed to have been introduced in 1003.2-1992 */
711539Srgrimes#define	GLOB_APPEND	0x0001	/* Append to output from previous call. */
721539Srgrimes#define	GLOB_DOOFFS	0x0002	/* Use gl_offs. */
731539Srgrimes#define	GLOB_ERR	0x0004	/* Return on error. */
741539Srgrimes#define	GLOB_MARK	0x0008	/* Append / to matching directories. */
751539Srgrimes#define	GLOB_NOCHECK	0x0010	/* Return pattern itself if nothing matches. */
761539Srgrimes#define	GLOB_NOSORT	0x0020	/* Don't sort. */
77100217Smikeh#define	GLOB_NOESCAPE	0x2000	/* Disable backslash escaping. */
781539Srgrimes
79100217Smikeh/* Error values returned by glob(3) */
80100217Smikeh#define	GLOB_NOSPACE	(-1)	/* Malloc call failed. */
81100217Smikeh#define	GLOB_ABORTED	(-2)	/* Unignored error. */
82100217Smikeh#define	GLOB_NOMATCH	(-3)	/* No match and GLOB_NOCHECK was not set. */
83100217Smikeh#define	GLOB_NOSYS	(-4)	/* Obsolete: source comptability only. */
84100217Smikeh#endif /* __POSIX_VISIBLE >= 199209 */
85100217Smikeh
86100217Smikeh#if __BSD_VISIBLE
871539Srgrimes#define	GLOB_ALTDIRFUNC	0x0040	/* Use alternately specified directory funcs. */
881539Srgrimes#define	GLOB_BRACE	0x0080	/* Expand braces ala csh. */
891539Srgrimes#define	GLOB_MAGCHAR	0x0100	/* Pattern had globbing characters. */
901539Srgrimes#define	GLOB_NOMAGIC	0x0200	/* GLOB_NOCHECK without magic chars (csh). */
911539Srgrimes#define	GLOB_QUOTE	0x0400	/* Quote special chars with \. */
921539Srgrimes#define	GLOB_TILDE	0x0800	/* Expand tilde names from the passwd file. */
9380525Smikeh#define	GLOB_LIMIT	0x1000	/* limit number of returned paths */
941539Srgrimes
95100217Smikeh/* source compatibility, these are the old names */
9680525Smikeh#define GLOB_MAXPATH	GLOB_LIMIT
97100217Smikeh#define	GLOB_ABEND	GLOB_ABORTED
98100217Smikeh#endif /* __BSD_VISIBLE */
9980525Smikeh
1001539Srgrimes__BEGIN_DECLS
101228754Seadlerint	glob(const char * __restrict, int,
102228754Seadler	int (*)(const char *, int), glob_t * __restrict);
10393032Simpvoid	globfree(glob_t *);
1041539Srgrimes__END_DECLS
1051539Srgrimes
1061539Srgrimes#endif /* !_GLOB_H_ */
107