* sysdeps/unix/sysv/linux/opensock.c: Include <string.h>.
[glibc.git] / io / ftw.h
blob5ed908e9159f00b3ffdd569ca1d98e3cea8cd8c1
1 /* Copyright (C) 1992, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
20 * X/Open Portability Guide 4.2: ftw.h
23 #ifndef _FTW_H
24 #define _FTW_H 1
26 #include <features.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
32 __BEGIN_DECLS
34 /* Values for the FLAG argument to the user function passed to `ftw'
35 and 'nftw'. */
36 enum
38 FTW_F, /* Regular file. */
39 #define FTW_F FTW_F
40 FTW_D, /* Directory. */
41 #define FTW_D FTW_D
42 FTW_DNR, /* Unreadable directory. */
43 #define FTW_DNR FTW_DNR
44 FTW_NS, /* Unstatable file. */
45 #define FTW_NS FTW_NS
47 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
49 FTW_SL, /* Symbolic link. */
50 # define FTW_SL FTW_SL
51 #endif
53 #ifdef __USE_XOPEN_EXTENDED
54 /* These flags are only passed from the `nftw' function. */
55 FTW_DP, /* Directory, all subdirs have been visited. */
56 # define FTW_DP FTW_DP
57 FTW_SLN /* Symbolic link naming non-existing file. */
58 # define FTW_SLN FTW_SLN
60 #endif /* extended X/Open */
64 #ifdef __USE_XOPEN_EXTENDED
65 /* Flags for fourth argument of `nftw'. */
66 enum
68 FTW_PHYS = 1, /* Perform physical walk, ignore symlinks. */
69 # define FTW_PHYS FTW_PHYS
70 FTW_MOUNT = 2, /* Report only files on same file system as the
71 argument. */
72 # define FTW_MOUNT FTW_MOUNT
73 FTW_CHDIR = 4, /* Change to current directory while processing it. */
74 # define FTW_CHDIR FTW_CHDIR
75 FTW_DEPTH = 8 /* Report files in directory before directory itself.*/
76 # define FTW_DEPTH FTW_DEPTH
79 /* Structure used for fourth argument to callback function for `nftw'. */
80 struct FTW
82 int base;
83 int level;
85 #endif /* extended X/Open */
88 /* Convenient types for callback functions. */
89 typedef int (*__ftw_func_t) (__const char *__filename,
90 __const struct stat *__status, int __flag);
91 #ifdef __USE_LARGEFILE64
92 typedef int (*__ftw64_func_t) (__const char *__filename,
93 __const struct stat64 *__status, int __flag);
94 #endif
95 #ifdef __USE_XOPEN_EXTENDED
96 typedef int (*__nftw_func_t) (__const char *__filename,
97 __const struct stat *__status, int __flag,
98 struct FTW *__info);
99 # ifdef __USE_LARGEFILE64
100 typedef int (*__nftw64_func_t) (__const char *__filename,
101 __const struct stat64 *__status,
102 int __flag, struct FTW *__info);
103 # endif
104 #endif
106 /* Call a function on every element in a directory tree. */
107 #ifndef __USE_FILE_OFFSET64
108 extern int ftw (__const char *__dir, __ftw_func_t __func, int __descriptors)
109 __THROW;
110 #else
111 # ifdef __REDIRECT
112 extern int __REDIRECT (ftw, (__const char *__dir, __ftw_func_t __func,
113 int __descriptors) __THROW, ftw64);
114 # else
115 # define ftw ftw64
116 # endif
117 #endif
118 #ifdef __USE_LARGEFILE64
119 extern int ftw64 (__const char *__dir, __ftw64_func_t __func,
120 int __descriptors) __THROW;
121 #endif
123 #ifdef __USE_XOPEN_EXTENDED
124 /* Call a function on every element in a directory tree. FLAG allows
125 to specify the behaviour more detailed. */
126 # ifndef __USE_FILE_OFFSET64
127 extern int nftw (__const char *__dir, __nftw_func_t __func, int __descriptors,
128 int __flag) __THROW;
129 # else
130 # ifdef __REDIRECT
131 extern int __REDIRECT (nftw, (__const char *__dir, __nftw_func_t __func,
132 int __descriptors, int __flag) __THROW, nftw64);
133 # else
134 # define nftw nftw64
135 # endif
136 # endif
137 # ifdef __USE_LARGEFILE64
138 extern int nftw64 (__const char *__dir, __nftw64_func_t __func,
139 int __descriptors, int __flag) __THROW;
140 # endif
141 #endif
143 __END_DECLS
145 #endif /* ftw.h */