17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate 237c478bd9Sstevel@tonic-gate /* 24*b59b3655SGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 257c478bd9Sstevel@tonic-gate * Copyright 1985, 1992 by Mortice Kern Systems Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 2871939b8fSGary Mills /* 2971939b8fSGary Mills * Copyright (c) 1989, 1993 3071939b8fSGary Mills * The Regents of the University of California. All rights reserved. 3171939b8fSGary Mills * 3271939b8fSGary Mills * This code is derived from software contributed to Berkeley by 3371939b8fSGary Mills * Guido van Rossum. 3471939b8fSGary Mills * 3571939b8fSGary Mills * Redistribution and use in source and binary forms, with or without 3671939b8fSGary Mills * modification, are permitted provided that the following conditions 3771939b8fSGary Mills * are met: 3871939b8fSGary Mills * 1. Redistributions of source code must retain the above copyright 3971939b8fSGary Mills * notice, this list of conditions and the following disclaimer. 4071939b8fSGary Mills * 2. Redistributions in binary form must reproduce the above copyright 4171939b8fSGary Mills * notice, this list of conditions and the following disclaimer in the 4271939b8fSGary Mills * documentation and/or other materials provided with the distribution. 4371939b8fSGary Mills * 3. Neither the name of the University nor the names of its contributors 4471939b8fSGary Mills * may be used to endorse or promote products derived from this software 4571939b8fSGary Mills * without specific prior written permission. 4671939b8fSGary Mills * 4771939b8fSGary Mills * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 4871939b8fSGary Mills * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4971939b8fSGary Mills * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5071939b8fSGary Mills * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5171939b8fSGary Mills * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5271939b8fSGary Mills * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5371939b8fSGary Mills * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5471939b8fSGary Mills * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5571939b8fSGary Mills * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5671939b8fSGary Mills * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5771939b8fSGary Mills * SUCH DAMAGE. 5871939b8fSGary Mills * 5971939b8fSGary Mills * @(#)glob.h 8.1 (Berkeley) 6/2/93 6071939b8fSGary Mills */ 6171939b8fSGary Mills 6271939b8fSGary Mills /* 6371939b8fSGary Mills * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 6471939b8fSGary Mills * Use is subject to license terms. 6571939b8fSGary Mills * Copyright (c) 2013 Gary Mills 6671939b8fSGary Mills */ 6771939b8fSGary Mills 687c478bd9Sstevel@tonic-gate #ifndef _GLOB_H 697c478bd9Sstevel@tonic-gate #define _GLOB_H 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 727c478bd9Sstevel@tonic-gate #include <sys/types.h> 7371939b8fSGary Mills #include <sys/stat.h> 7471939b8fSGary Mills #include <dirent.h> 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate #ifdef __cplusplus 777c478bd9Sstevel@tonic-gate extern "C" { 787c478bd9Sstevel@tonic-gate #endif 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate typedef struct glob_t { 8171939b8fSGary Mills /* 8271939b8fSGary Mills * Members specified by POSIX 8371939b8fSGary Mills */ 8471939b8fSGary Mills size_t gl_pathc; /* Total count of paths matched by pattern */ 857c478bd9Sstevel@tonic-gate char **gl_pathv; /* List of matched pathnames */ 867c478bd9Sstevel@tonic-gate size_t gl_offs; /* # of slots reserved in gl_pathv */ 8771939b8fSGary Mills 8871939b8fSGary Mills /* 8971939b8fSGary Mills * Internal-use members: 9071939b8fSGary Mills * 9171939b8fSGary Mills * NB: The next two members are carried in both the 9271939b8fSGary Mills * libc backward compatibility wrapper functions and 9371939b8fSGary Mills * the extended functions. 9471939b8fSGary Mills */ 957c478bd9Sstevel@tonic-gate char **gl_pathp; /* gl_pathv + gl_offs */ 967c478bd9Sstevel@tonic-gate int gl_pathn; /* # of elements allocated */ 9771939b8fSGary Mills 9871939b8fSGary Mills /* 9971939b8fSGary Mills * Non-POSIX extensions 10071939b8fSGary Mills * 10171939b8fSGary Mills * NB: The following members are not carried in 10271939b8fSGary Mills * the libc backward compatibility wrapper functions. 10371939b8fSGary Mills */ 10471939b8fSGary Mills int gl_matchc; /* Count of paths matching pattern. */ 10571939b8fSGary Mills int gl_flags; /* Copy of flags parameter to glob. */ 10671939b8fSGary Mills struct stat **gl_statv; /* Stat entries corresponding to gl_pathv */ 10771939b8fSGary Mills 10871939b8fSGary Mills /* 10971939b8fSGary Mills * Alternate filesystem access methods for glob; replacement 11071939b8fSGary Mills * versions of closedir(3), readdir(3), opendir(3), stat(2) 11171939b8fSGary Mills * and lstat(2). 11271939b8fSGary Mills */ 11371939b8fSGary Mills void (*gl_closedir)(void *); 11471939b8fSGary Mills struct dirent *(*gl_readdir)(void *); 11571939b8fSGary Mills void *(*gl_opendir)(const char *); 11671939b8fSGary Mills int (*gl_lstat)(const char *, struct stat *); 11771939b8fSGary Mills int (*gl_stat)(const char *, struct stat *); 1187c478bd9Sstevel@tonic-gate } glob_t; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 12171939b8fSGary Mills * POSIX "flags" argument to glob function. 1227c478bd9Sstevel@tonic-gate */ 1237c478bd9Sstevel@tonic-gate #define GLOB_ERR 0x0001 /* Don't continue on directory error */ 1247c478bd9Sstevel@tonic-gate #define GLOB_MARK 0x0002 /* Mark directories with trailing / */ 1257c478bd9Sstevel@tonic-gate #define GLOB_NOSORT 0x0004 /* Don't sort pathnames */ 1267c478bd9Sstevel@tonic-gate #define GLOB_NOCHECK 0x0008 /* Return unquoted arg if no match */ 1277c478bd9Sstevel@tonic-gate #define GLOB_DOOFFS 0x0010 /* Ignore gl_offs unless set */ 1287c478bd9Sstevel@tonic-gate #define GLOB_APPEND 0x0020 /* Append to previous glob_t */ 1297c478bd9Sstevel@tonic-gate #define GLOB_NOESCAPE 0x0040 /* Backslashes do not quote M-chars */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 13271939b8fSGary Mills * Non-POSIX "flags" argument to glob function, from OpenBSD. 13371939b8fSGary Mills */ 13471939b8fSGary Mills #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 13571939b8fSGary Mills #define GLOB_POSIX 0x007F /* All POSIX flags */ 13671939b8fSGary Mills #define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ 13771939b8fSGary Mills #define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ 13871939b8fSGary Mills #define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ 13971939b8fSGary Mills #define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ 14071939b8fSGary Mills #define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ 14171939b8fSGary Mills #define GLOB_LIMIT 0x2000 /* Limit pattern match output to ARG_MAX */ 14271939b8fSGary Mills #define GLOB_KEEPSTAT 0x4000 /* Retain stat data for paths in gl_statv. */ 14371939b8fSGary Mills #define GLOB_ALTDIRFUNC 0x8000 /* Use alternately specified directory funcs. */ 14471939b8fSGary Mills #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 14571939b8fSGary Mills 14671939b8fSGary Mills /* 1477c478bd9Sstevel@tonic-gate * Error returns from "glob" 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate #define GLOB_NOSYS (-4) /* function not supported (XPG4) */ 1507c478bd9Sstevel@tonic-gate #define GLOB_NOMATCH (-3) /* Pattern does not match */ 1517c478bd9Sstevel@tonic-gate #define GLOB_NOSPACE (-2) /* Not enough memory */ 1527c478bd9Sstevel@tonic-gate #define GLOB_ABORTED (-1) /* GLOB_ERR set or errfunc return!=0 */ 15371939b8fSGary Mills #define GLOB_ABEND GLOB_ABORTED /* backward compatibility */ 15471939b8fSGary Mills 15571939b8fSGary Mills #ifdef __PRAGMA_REDEFINE_EXTNAME 15671939b8fSGary Mills #pragma redefine_extname glob _glob_ext 15771939b8fSGary Mills #pragma redefine_extname globfree _globfree_ext 15871939b8fSGary Mills #else /* __PRAGMA_REDEFINE_EXTNAME */ 15971939b8fSGary Mills #define glob _glob_ext 16071939b8fSGary Mills #define globfree _globfree_ext 16171939b8fSGary Mills #endif /* __PRAGMA_REDEFINE_EXTNAME */ 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate extern int glob(const char *_RESTRICT_KYWD, int, int(*)(const char *, int), 1647c478bd9Sstevel@tonic-gate glob_t *_RESTRICT_KYWD); 1657c478bd9Sstevel@tonic-gate extern void globfree(glob_t *); 16671939b8fSGary Mills 1677c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate #endif 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate #endif /* _GLOB_H */ 172