]>
Commit | Line | Data |
---|---|---|
a784e502 | 1 | /* Copyright (C) 1992,1996-1999,2003,2004,2012 Free Software Foundation, Inc. |
54d79e99 | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
54d79e99 | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
28f540f4 | 8 | |
54d79e99 UD |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
28f540f4 | 13 | |
41bdb6e2 AJ |
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. */ | |
28f540f4 RM |
18 | |
19 | /* | |
54d79e99 | 20 | * X/Open Portability Guide 4.2: ftw.h |
28f540f4 RM |
21 | */ |
22 | ||
23 | #ifndef _FTW_H | |
28f540f4 | 24 | #define _FTW_H 1 |
5107cf1d | 25 | |
28f540f4 RM |
26 | #include <features.h> |
27 | ||
76b87c03 | 28 | #include <sys/types.h> |
f4017d20 | 29 | #include <sys/stat.h> |
28f540f4 | 30 | |
28f540f4 | 31 | |
1fb05e3d UD |
32 | __BEGIN_DECLS |
33 | ||
76b87c03 UD |
34 | /* Values for the FLAG argument to the user function passed to `ftw' |
35 | and 'nftw'. */ | |
36 | enum | |
37 | { | |
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 | |
46 | ||
d951286f | 47 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
76b87c03 UD |
48 | |
49 | FTW_SL, /* Symbolic link. */ | |
50 | # define FTW_SL FTW_SL | |
d951286f | 51 | #endif |
76b87c03 | 52 | |
d951286f | 53 | #ifdef __USE_XOPEN_EXTENDED |
76b87c03 UD |
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 | |
59 | ||
60 | #endif /* extended X/Open */ | |
61 | }; | |
62 | ||
63 | ||
64 | #ifdef __USE_XOPEN_EXTENDED | |
65 | /* Flags for fourth argument of `nftw'. */ | |
66 | enum | |
67 | { | |
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 | |
ca10f338 UD |
77 | # ifdef __USE_GNU |
78 | , | |
79 | FTW_ACTIONRETVAL = 16 /* Assume callback to return FTW_* values instead of | |
80 | zero to continue and non-zero to terminate. */ | |
81 | # define FTW_ACTIONRETVAL FTW_ACTIONRETVAL | |
82 | # endif | |
76b87c03 UD |
83 | }; |
84 | ||
ca10f338 UD |
85 | #ifdef __USE_GNU |
86 | /* Return values from callback functions. */ | |
87 | enum | |
88 | { | |
89 | FTW_CONTINUE = 0, /* Continue with next sibling or for FTW_D with the | |
90 | first child. */ | |
91 | # define FTW_CONTINUE FTW_CONTINUE | |
92 | FTW_STOP = 1, /* Return from `ftw' or `nftw' with FTW_STOP as return | |
93 | value. */ | |
94 | # define FTW_STOP FTW_STOP | |
95 | FTW_SKIP_SUBTREE = 2, /* Only meaningful for FTW_D: Don't walk through the | |
96 | subtree, instead just continue with its next | |
97 | sibling. */ | |
98 | # define FTW_SKIP_SUBTREE FTW_SKIP_SUBTREE | |
99 | FTW_SKIP_SIBLINGS = 3,/* Continue with FTW_DP callback for current directory | |
100 | (if FTW_DEPTH) and then its siblings. */ | |
101 | # define FTW_SKIP_SIBLINGS FTW_SKIP_SIBLINGS | |
102 | }; | |
103 | #endif | |
104 | ||
76b87c03 UD |
105 | /* Structure used for fourth argument to callback function for `nftw'. */ |
106 | struct FTW | |
107 | { | |
108 | int base; | |
109 | int level; | |
110 | }; | |
111 | #endif /* extended X/Open */ | |
112 | ||
113 | ||
114 | /* Convenient types for callback functions. */ | |
a784e502 UD |
115 | typedef int (*__ftw_func_t) (const char *__filename, |
116 | const struct stat *__status, int __flag); | |
fdacb17d | 117 | #ifdef __USE_LARGEFILE64 |
a784e502 UD |
118 | typedef int (*__ftw64_func_t) (const char *__filename, |
119 | const struct stat64 *__status, int __flag); | |
1cab5444 | 120 | #endif |
76b87c03 | 121 | #ifdef __USE_XOPEN_EXTENDED |
a784e502 UD |
122 | typedef int (*__nftw_func_t) (const char *__filename, |
123 | const struct stat *__status, int __flag, | |
c1422e5b | 124 | struct FTW *__info); |
9756dfe1 | 125 | # ifdef __USE_LARGEFILE64 |
a784e502 UD |
126 | typedef int (*__nftw64_func_t) (const char *__filename, |
127 | const struct stat64 *__status, | |
c1422e5b | 128 | int __flag, struct FTW *__info); |
1cab5444 | 129 | # endif |
76b87c03 UD |
130 | #endif |
131 | ||
2c008571 UD |
132 | /* Call a function on every element in a directory tree. |
133 | ||
134 | This function is a possible cancellation point and therefore not | |
135 | marked with __THROW. */ | |
dfd2257a | 136 | #ifndef __USE_FILE_OFFSET64 |
a784e502 | 137 | extern int ftw (const char *__dir, __ftw_func_t __func, int __descriptors) |
8a1f658b | 138 | __nonnull ((1, 2)); |
dfd2257a | 139 | #else |
01cad722 | 140 | # ifdef __REDIRECT |
a784e502 | 141 | extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func, |
8a1f658b | 142 | int __descriptors), ftw64) __nonnull ((1, 2)); |
01cad722 | 143 | # else |
9b26f5c4 | 144 | # define ftw ftw64 |
01cad722 | 145 | # endif |
dfd2257a UD |
146 | #endif |
147 | #ifdef __USE_LARGEFILE64 | |
a784e502 | 148 | extern int ftw64 (const char *__dir, __ftw64_func_t __func, |
8a1f658b | 149 | int __descriptors) __nonnull ((1, 2)); |
dfd2257a | 150 | #endif |
76b87c03 UD |
151 | |
152 | #ifdef __USE_XOPEN_EXTENDED | |
153 | /* Call a function on every element in a directory tree. FLAG allows | |
2c008571 UD |
154 | to specify the behaviour more detailed. |
155 | ||
156 | This function is a possible cancellation point and therefore not | |
157 | marked with __THROW. */ | |
dfd2257a | 158 | # ifndef __USE_FILE_OFFSET64 |
a784e502 | 159 | extern int nftw (const char *__dir, __nftw_func_t __func, int __descriptors, |
8a1f658b | 160 | int __flag) __nonnull ((1, 2)); |
dfd2257a | 161 | # else |
01cad722 | 162 | # ifdef __REDIRECT |
a784e502 | 163 | extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func, |
8a1f658b UD |
164 | int __descriptors, int __flag), nftw64) |
165 | __nonnull ((1, 2)); | |
01cad722 UD |
166 | # else |
167 | # define nftw nftw64 | |
168 | # endif | |
dfd2257a UD |
169 | # endif |
170 | # ifdef __USE_LARGEFILE64 | |
a784e502 | 171 | extern int nftw64 (const char *__dir, __nftw64_func_t __func, |
8a1f658b | 172 | int __descriptors, int __flag) __nonnull ((1, 2)); |
dfd2257a | 173 | # endif |
76b87c03 | 174 | #endif |
28f540f4 | 175 | |
1fb05e3d UD |
176 | __END_DECLS |
177 | ||
28f540f4 | 178 | #endif /* ftw.h */ |