1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #ifndef _FTW_H 32*7c478bd9Sstevel@tonic-gate #define _FTW_H 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 42*7c478bd9Sstevel@tonic-gate extern "C" { 43*7c478bd9Sstevel@tonic-gate #endif 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * Codes for the third argument to the user-supplied function 47*7c478bd9Sstevel@tonic-gate * which is passed as the second argument to ftwalk 48*7c478bd9Sstevel@tonic-gate */ 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #define FTW_F 0 /* file */ 51*7c478bd9Sstevel@tonic-gate #define FTW_D 1 /* directory */ 52*7c478bd9Sstevel@tonic-gate #define FTW_DNR 2 /* directory without read permission */ 53*7c478bd9Sstevel@tonic-gate #define FTW_NS 3 /* unknown type, stat failed */ 54*7c478bd9Sstevel@tonic-gate #define FTW_SL 4 /* symbolic link */ 55*7c478bd9Sstevel@tonic-gate #define FTW_DP 6 /* directory */ 56*7c478bd9Sstevel@tonic-gate #define FTW_SLN 7 /* symbolic link that points to nonexistent file */ 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate /* 59*7c478bd9Sstevel@tonic-gate * Codes for the fourth argument to ftwalk. You can specify the 60*7c478bd9Sstevel@tonic-gate * union of these flags. 61*7c478bd9Sstevel@tonic-gate */ 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate #define FTW_PHYS 01 /* use lstat instead of stat */ 64*7c478bd9Sstevel@tonic-gate #define FTW_MOUNT 02 /* do not cross a mount point */ 65*7c478bd9Sstevel@tonic-gate #define FTW_CHDIR 04 /* chdir to each directory before reading */ 66*7c478bd9Sstevel@tonic-gate #define FTW_DEPTH 010 /* call descendents before calling the parent */ 67*7c478bd9Sstevel@tonic-gate #define FTW_ANYERR 020 /* return FTW_NS on any stat failure */ 68*7c478bd9Sstevel@tonic-gate #define FTW_HOPTION 040 /* private interface for find utility */ 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2) 71*7c478bd9Sstevel@tonic-gate struct FTW 72*7c478bd9Sstevel@tonic-gate { 73*7c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) 74*7c478bd9Sstevel@tonic-gate int __quit; 75*7c478bd9Sstevel@tonic-gate #else 76*7c478bd9Sstevel@tonic-gate int quit; 77*7c478bd9Sstevel@tonic-gate #endif 78*7c478bd9Sstevel@tonic-gate int base; 79*7c478bd9Sstevel@tonic-gate int level; 80*7c478bd9Sstevel@tonic-gate }; 81*7c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */ 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate /* 84*7c478bd9Sstevel@tonic-gate * legal values for quit 85*7c478bd9Sstevel@tonic-gate */ 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate #define FTW_SKD 1 88*7c478bd9Sstevel@tonic-gate #define FTW_FOLLOW 2 89*7c478bd9Sstevel@tonic-gate #define FTW_PRUNE 4 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate /* large file compilation environment setup */ 92*7c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64 93*7c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 94*7c478bd9Sstevel@tonic-gate #pragma redefine_extname _xftw _xftw64 95*7c478bd9Sstevel@tonic-gate #pragma redefine_extname _ftw _ftw64 96*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(_XPG5) 97*7c478bd9Sstevel@tonic-gate #pragma redefine_extname nftw nftw64 98*7c478bd9Sstevel@tonic-gate #endif 99*7c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 100*7c478bd9Sstevel@tonic-gate #define _xftw _xftw64 101*7c478bd9Sstevel@tonic-gate #define _ftw _ftw64 102*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(_XPG5) 103*7c478bd9Sstevel@tonic-gate #define nftw nftw64 104*7c478bd9Sstevel@tonic-gate #endif 105*7c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 106*7c478bd9Sstevel@tonic-gate #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* In the LP64 compilation environment, all APIs are already large file */ 109*7c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE) 110*7c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 111*7c478bd9Sstevel@tonic-gate #pragma redefine_extname _xftw64 _xftw 112*7c478bd9Sstevel@tonic-gate #pragma redefine_extname _ftw64 _ftw 113*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(_XPG5) 114*7c478bd9Sstevel@tonic-gate #pragma redefine_extname nftw64 nftw 115*7c478bd9Sstevel@tonic-gate #endif 116*7c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 117*7c478bd9Sstevel@tonic-gate #define _xftw64 _xftw 118*7c478bd9Sstevel@tonic-gate #define _ftw64 _ftw 119*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(_XPG5) 120*7c478bd9Sstevel@tonic-gate #define nftw64 nftw 121*7c478bd9Sstevel@tonic-gate #endif 122*7c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 123*7c478bd9Sstevel@tonic-gate #endif /* _LP64 && _LARGEFILE64_SOURCE */ 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate extern int ftw(const char *, 128*7c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat *, int), int); 129*7c478bd9Sstevel@tonic-gate extern int _xftw(int, const char *, 130*7c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat *, int), int); 131*7c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2) 132*7c478bd9Sstevel@tonic-gate extern int nftw(const char *, 133*7c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat *, int, struct FTW *), 134*7c478bd9Sstevel@tonic-gate int, int); 135*7c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */ 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate /* 138*7c478bd9Sstevel@tonic-gate * transitional large file interface versions 139*7c478bd9Sstevel@tonic-gate */ 140*7c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 141*7c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 142*7c478bd9Sstevel@tonic-gate extern int ftw64(const char *, 143*7c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat64 *, int), int); 144*7c478bd9Sstevel@tonic-gate extern int _xftw64(int, const char *, 145*7c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat64 *, int), int); 146*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) 147*7c478bd9Sstevel@tonic-gate extern int nftw64(const char *, 148*7c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat64 *, int, struct FTW *), 149*7c478bd9Sstevel@tonic-gate int, int); 150*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) */ 151*7c478bd9Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE .. */ 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 154*7c478bd9Sstevel@tonic-gate 155*7c478bd9Sstevel@tonic-gate extern int ftw(), _xftw(); 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2) 158*7c478bd9Sstevel@tonic-gate extern int nftw(); 159*7c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */ 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate /* transitional large file interface versions */ 162*7c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 163*7c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 164*7c478bd9Sstevel@tonic-gate extern int ftw64(); 165*7c478bd9Sstevel@tonic-gate extern int _xftw64(); 166*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) 167*7c478bd9Sstevel@tonic-gate extern int nftw64(); 168*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) */ 169*7c478bd9Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE .. */ 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate #define _XFTWVER 2 /* version of file tree walk */ 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate #define ftw(path, fn, depth) _xftw(_XFTWVER, (path), (fn), (depth)) 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 178*7c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 179*7c478bd9Sstevel@tonic-gate #define ftw64(path, fn, depth) _xftw64(_XFTWVER, (path), (fn), (depth)) 180*7c478bd9Sstevel@tonic-gate #endif 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 183*7c478bd9Sstevel@tonic-gate } 184*7c478bd9Sstevel@tonic-gate #endif 185*7c478bd9Sstevel@tonic-gate 186*7c478bd9Sstevel@tonic-gate #endif /* _FTW_H */ 187