/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1989, 19934* The Regents of the University of California. All rights reserved.5*6* This code is derived from software contributed to Berkeley by7* Guido van Rossum.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17* 3. Neither the name of the University nor the names of its contributors18* may be used to endorse or promote products derived from this software19* without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND22* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE25* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31* SUCH DAMAGE.32*/3334#ifndef _GLOB_H_35#define _GLOB_H_3637#include <sys/cdefs.h>38#include <sys/_types.h>3940#ifndef _SIZE_T_DECLARED41typedef __size_t size_t;42#define _SIZE_T_DECLARED43#endif4445struct stat;46typedef struct {47size_t gl_pathc; /* Count of total paths so far. */48size_t gl_matchc; /* Count of paths matching pattern. */49size_t gl_offs; /* Reserved at beginning of gl_pathv. */50int gl_flags; /* Copy of flags parameter to glob. */51char **gl_pathv; /* List of paths matching pattern. */52/* Copy of error callback parameter to glob. */53union {54int (*gl_errfunc)(const char *, int);55#ifdef __BLOCKS__56int (^gl_errblk)(const char *, int);57#else58void *gl_errblk;59#endif60};6162/*63* Alternate filesystem access methods for glob; replacement64* versions of closedir(3), readdir(3), opendir(3), stat(2)65* and lstat(2).66*/67void (*gl_closedir)(void *);68struct dirent *(*gl_readdir)(void *);69void *(*gl_opendir)(const char *);70int (*gl_lstat)(const char *, struct stat *);71int (*gl_stat)(const char *, struct stat *);72} glob_t;7374#if __POSIX_VISIBLE >= 19920975/* Believed to have been introduced in 1003.2-1992 */76#define GLOB_APPEND 0x0001 /* Append to output from previous call. */77#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */78#define GLOB_ERR 0x0004 /* Return on error. */79#define GLOB_MARK 0x0008 /* Append / to matching directories. */80#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */81#define GLOB_NOSORT 0x0020 /* Don't sort. */82#define GLOB_NOESCAPE 0x2000 /* Disable backslash escaping. */8384/* Error values returned by glob(3) */85#define GLOB_NOSPACE (-1) /* Malloc call failed. */86#define GLOB_ABORTED (-2) /* Unignored error. */87#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */88#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */89#endif /* __POSIX_VISIBLE >= 199209 */9091#if __BSD_VISIBLE92#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */93#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */94#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */95#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */96#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */97#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */98#define GLOB_LIMIT 0x1000 /* limit number of returned paths */99#define _GLOB_ERR_BLOCK 0x08000000 /* (internal) error callback is a block */100101/* source compatibility, these are the old names */102#define GLOB_MAXPATH GLOB_LIMIT103#define GLOB_ABEND GLOB_ABORTED104#endif /* __BSD_VISIBLE */105106__BEGIN_DECLS107int glob(const char * __restrict, int,108int (*)(const char *, int), glob_t * __restrict);109#if defined(__BLOCKS__) && __BSD_VISIBLE110int glob_b(const char * __restrict, int,111int (^)(const char *, int), glob_t * __restrict);112#endif113void globfree(glob_t *);114__END_DECLS115116#endif /* !_GLOB_H_ */117118119