1f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes/* 2f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * Copyright (c) 1989, 1993 3f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * The Regents of the University of California. All rights reserved. 4f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * 5f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * This code is derived from software contributed to Berkeley by 6f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * Guido van Rossum. 7f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * 8f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * Redistribution and use in source and binary forms, with or without 9f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * modification, are permitted provided that the following conditions 10f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * are met: 11f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * 1. Redistributions of source code must retain the above copyright 12f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * notice, this list of conditions and the following disclaimer. 13f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * 2. Redistributions in binary form must reproduce the above copyright 14f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * notice, this list of conditions and the following disclaimer in the 15f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * documentation and/or other materials provided with the distribution. 16f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * 3. Neither the name of the University nor the names of its contributors 17f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * may be used to endorse or promote products derived from this software 18f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * without specific prior written permission. 19f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * 20f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * SUCH DAMAGE. 31f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * 32f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * @(#)glob.h 8.1 (Berkeley) 6/2/93 33f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * $FreeBSD$ 34f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes */ 35f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 36f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#ifndef _GLOB_H_ 37f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define _GLOB_H_ 38f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 39f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#include <sys/cdefs.h> 40f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#include <sys/types.h> 41f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 42f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughesstruct dirent; 43f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughesstruct stat; 44f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 45f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughestypedef struct { 46f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes size_t gl_pathc; /* Count of total paths so far. */ 47f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes size_t gl_matchc; /* Count of paths matching pattern. */ 48f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes size_t gl_offs; /* Reserved at beginning of gl_pathv. */ 49f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes int gl_flags; /* Copy of flags parameter to glob. */ 50f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes char** gl_pathv; /* List of paths matching pattern. */ 51f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 52f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes /* Copy of `__error_callback` parameter to glob. */ 53f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes int (*gl_errfunc)(const char* __failure_path, int __failure_errno); 54f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 55f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes /* 56f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * Alternate filesystem access methods for glob; replacement 57f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * versions of closedir(3), readdir(3), opendir(3), stat(2) 58f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes * and lstat(2). 59f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes */ 60f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes void (*gl_closedir)(void*); 61f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes struct dirent* (*gl_readdir)(void*); 62f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes void* (*gl_opendir)(const char*); 63f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes int (*gl_lstat)(const char*, struct stat*); 64f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes int (*gl_stat)(const char*, struct stat*); 65f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes} glob_t; 66f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 67f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes/* Believed to have been introduced in 1003.2-1992 */ 68f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ 69f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_DOOFFS 0x0002 /* Prepend `gl_offs` null pointers (leaving space for exec, say). */ 70f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_ERR 0x0004 /* Return on error. */ 71f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_MARK 0x0008 /* Append "/" to the names of returned directories. */ 72f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ 73f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_NOSORT 0x0020 /* Don't sort. */ 74f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_NOESCAPE 0x2000 /* Disable backslash escaping. */ 75f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 76f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes/* Error values returned by glob(3) */ 77f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_NOSPACE (-1) /* Malloc call failed. */ 78f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_ABORTED (-2) /* Unignored error. */ 79f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */ 80f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 81f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#if __USE_BSD 82f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ 83f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_BRACE 0x0080 /* Expand braces like csh. */ 84f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_MAGCHAR 0x0100 /* Set in `gl_flags` if the pattern had globbing characters. */ 85f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ 86f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ 87f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ 88f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#define GLOB_LIMIT 0x1000 /* limit number of returned paths */ 89f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#endif 90f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 91f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes__BEGIN_DECLS 92f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 93cc0fe6e8c0bb2dfb250522872be6facb4d4a0339Elliott Hughesint glob(const char* __pattern, int __flags, int (*__error_callback)(const char* __failure_path, int __failure_errno), glob_t* __result_ptr) __INTRODUCED_IN(28); 94cc0fe6e8c0bb2dfb250522872be6facb4d4a0339Elliott Hughesvoid globfree(glob_t* __result_ptr) __INTRODUCED_IN(28); 95f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 96f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes__END_DECLS 97f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes 98f1c568d1eac6d2baba62af35e5b9856fb7e98319Elliott Hughes#endif 99