]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (C) 1992-2019 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 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
28f540f4 RM |
17 | |
18 | /* | |
54d79e99 | 19 | * X/Open Portability Guide 4.2: ftw.h |
28f540f4 RM |
20 | */ |
21 | ||
22 | #ifndef _FTW_H | |
28f540f4 | 23 | #define _FTW_H 1 |
5107cf1d | 24 | |
28f540f4 RM |
25 | #include <features.h> |
26 | ||
76b87c03 | 27 | #include <sys/types.h> |
f4017d20 | 28 | #include <sys/stat.h> |
28f540f4 | 29 | |
28f540f4 | 30 | |
1fb05e3d UD |
31 | __BEGIN_DECLS |
32 | ||
76b87c03 UD |
33 | /* Values for the FLAG argument to the user function passed to `ftw' |
34 | and 'nftw'. */ | |
35 | enum | |
36 | { | |
37 | FTW_F, /* Regular file. */ | |
38 | #define FTW_F FTW_F | |
39 | FTW_D, /* Directory. */ | |
40 | #define FTW_D FTW_D | |
41 | FTW_DNR, /* Unreadable directory. */ | |
42 | #define FTW_DNR FTW_DNR | |
43 | FTW_NS, /* Unstatable file. */ | |
44 | #define FTW_NS FTW_NS | |
45 | ||
498afc54 | 46 | #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED |
76b87c03 UD |
47 | |
48 | FTW_SL, /* Symbolic link. */ | |
49 | # define FTW_SL FTW_SL | |
d951286f | 50 | #endif |
76b87c03 | 51 | |
d951286f | 52 | #ifdef __USE_XOPEN_EXTENDED |
76b87c03 UD |
53 | /* These flags are only passed from the `nftw' function. */ |
54 | FTW_DP, /* Directory, all subdirs have been visited. */ | |
55 | # define FTW_DP FTW_DP | |
56 | FTW_SLN /* Symbolic link naming non-existing file. */ | |
57 | # define FTW_SLN FTW_SLN | |
58 | ||
59 | #endif /* extended X/Open */ | |
60 | }; | |
61 | ||
62 | ||
63 | #ifdef __USE_XOPEN_EXTENDED | |
64 | /* Flags for fourth argument of `nftw'. */ | |
65 | enum | |
66 | { | |
67 | FTW_PHYS = 1, /* Perform physical walk, ignore symlinks. */ | |
68 | # define FTW_PHYS FTW_PHYS | |
69 | FTW_MOUNT = 2, /* Report only files on same file system as the | |
70 | argument. */ | |
71 | # define FTW_MOUNT FTW_MOUNT | |
72 | FTW_CHDIR = 4, /* Change to current directory while processing it. */ | |
73 | # define FTW_CHDIR FTW_CHDIR | |
74 | FTW_DEPTH = 8 /* Report files in directory before directory itself.*/ | |
75 | # define FTW_DEPTH FTW_DEPTH | |
ca10f338 UD |
76 | # ifdef __USE_GNU |
77 | , | |
78 | FTW_ACTIONRETVAL = 16 /* Assume callback to return FTW_* values instead of | |
79 | zero to continue and non-zero to terminate. */ | |
80 | # define FTW_ACTIONRETVAL FTW_ACTIONRETVAL | |
81 | # endif | |
76b87c03 UD |
82 | }; |
83 | ||
ca10f338 UD |
84 | #ifdef __USE_GNU |
85 | /* Return values from callback functions. */ | |
86 | enum | |
87 | { | |
88 | FTW_CONTINUE = 0, /* Continue with next sibling or for FTW_D with the | |
89 | first child. */ | |
90 | # define FTW_CONTINUE FTW_CONTINUE | |
91 | FTW_STOP = 1, /* Return from `ftw' or `nftw' with FTW_STOP as return | |
92 | value. */ | |
93 | # define FTW_STOP FTW_STOP | |
94 | FTW_SKIP_SUBTREE = 2, /* Only meaningful for FTW_D: Don't walk through the | |
95 | subtree, instead just continue with its next | |
96 | sibling. */ | |
97 | # define FTW_SKIP_SUBTREE FTW_SKIP_SUBTREE | |
98 | FTW_SKIP_SIBLINGS = 3,/* Continue with FTW_DP callback for current directory | |
99 | (if FTW_DEPTH) and then its siblings. */ | |
100 | # define FTW_SKIP_SIBLINGS FTW_SKIP_SIBLINGS | |
101 | }; | |
102 | #endif | |
103 | ||
76b87c03 UD |
104 | /* Structure used for fourth argument to callback function for `nftw'. */ |
105 | struct FTW | |
106 | { | |
107 | int base; | |
108 | int level; | |
109 | }; | |
110 | #endif /* extended X/Open */ | |
111 | ||
112 | ||
113 | /* Convenient types for callback functions. */ | |
a784e502 UD |
114 | typedef int (*__ftw_func_t) (const char *__filename, |
115 | const struct stat *__status, int __flag); | |
fdacb17d | 116 | #ifdef __USE_LARGEFILE64 |
a784e502 UD |
117 | typedef int (*__ftw64_func_t) (const char *__filename, |
118 | const struct stat64 *__status, int __flag); | |
1cab5444 | 119 | #endif |
76b87c03 | 120 | #ifdef __USE_XOPEN_EXTENDED |
a784e502 UD |
121 | typedef int (*__nftw_func_t) (const char *__filename, |
122 | const struct stat *__status, int __flag, | |
c1422e5b | 123 | struct FTW *__info); |
9756dfe1 | 124 | # ifdef __USE_LARGEFILE64 |
a784e502 UD |
125 | typedef int (*__nftw64_func_t) (const char *__filename, |
126 | const struct stat64 *__status, | |
c1422e5b | 127 | int __flag, struct FTW *__info); |
1cab5444 | 128 | # endif |
76b87c03 UD |
129 | #endif |
130 | ||
2c008571 UD |
131 | /* Call a function on every element in a directory tree. |
132 | ||
133 | This function is a possible cancellation point and therefore not | |
134 | marked with __THROW. */ | |
dfd2257a | 135 | #ifndef __USE_FILE_OFFSET64 |
a784e502 | 136 | extern int ftw (const char *__dir, __ftw_func_t __func, int __descriptors) |
8a1f658b | 137 | __nonnull ((1, 2)); |
dfd2257a | 138 | #else |
01cad722 | 139 | # ifdef __REDIRECT |
a784e502 | 140 | extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func, |
8a1f658b | 141 | int __descriptors), ftw64) __nonnull ((1, 2)); |
01cad722 | 142 | # else |
9b26f5c4 | 143 | # define ftw ftw64 |
01cad722 | 144 | # endif |
dfd2257a UD |
145 | #endif |
146 | #ifdef __USE_LARGEFILE64 | |
a784e502 | 147 | extern int ftw64 (const char *__dir, __ftw64_func_t __func, |
8a1f658b | 148 | int __descriptors) __nonnull ((1, 2)); |
dfd2257a | 149 | #endif |
76b87c03 UD |
150 | |
151 | #ifdef __USE_XOPEN_EXTENDED | |
152 | /* Call a function on every element in a directory tree. FLAG allows | |
2c008571 UD |
153 | to specify the behaviour more detailed. |
154 | ||
155 | This function is a possible cancellation point and therefore not | |
156 | marked with __THROW. */ | |
dfd2257a | 157 | # ifndef __USE_FILE_OFFSET64 |
a784e502 | 158 | extern int nftw (const char *__dir, __nftw_func_t __func, int __descriptors, |
8a1f658b | 159 | int __flag) __nonnull ((1, 2)); |
dfd2257a | 160 | # else |
01cad722 | 161 | # ifdef __REDIRECT |
a784e502 | 162 | extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func, |
8a1f658b UD |
163 | int __descriptors, int __flag), nftw64) |
164 | __nonnull ((1, 2)); | |
01cad722 UD |
165 | # else |
166 | # define nftw nftw64 | |
167 | # endif | |
dfd2257a UD |
168 | # endif |
169 | # ifdef __USE_LARGEFILE64 | |
a784e502 | 170 | extern int nftw64 (const char *__dir, __nftw64_func_t __func, |
8a1f658b | 171 | int __descriptors, int __flag) __nonnull ((1, 2)); |
dfd2257a | 172 | # endif |
76b87c03 | 173 | #endif |
28f540f4 | 174 | |
1fb05e3d UD |
175 | __END_DECLS |
176 | ||
28f540f4 | 177 | #endif /* ftw.h */ |