OSDN Git Service

mkostemp: fix implementation
[uclinux-h8/uClibc.git] / include / ftw.h
1 /* Copyright (C) 1992,1996-1999,2003,2004 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
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.
8
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.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17
18 /*
19  *      X/Open Portability Guide 4.2: ftw.h
20  */
21
22 #ifndef _FTW_H
23 #define _FTW_H  1
24
25 #include <features.h>
26
27 #include <sys/types.h>
28 #include <sys/stat.h>
29
30
31 __BEGIN_DECLS
32
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
46 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
47
48   FTW_SL,               /* Symbolic link.  */
49 # define FTW_SL  FTW_SL
50 #endif
51
52 #ifdef __USE_XOPEN_EXTENDED
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
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
82 };
83
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
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.  */
114 typedef int (*__ftw_func_t) (const char *__filename,
115                              const struct stat *__status, int __flag);
116 #ifdef __USE_LARGEFILE64
117 typedef int (*__ftw64_func_t) (const char *__filename,
118                                const struct stat64 *__status, int __flag);
119 #endif
120 #ifdef __USE_XOPEN_EXTENDED
121 typedef int (*__nftw_func_t) (const char *__filename,
122                               const struct stat *__status, int __flag,
123                               struct FTW *__info);
124 # ifdef __USE_LARGEFILE64
125 typedef int (*__nftw64_func_t) (const char *__filename,
126                                 const struct stat64 *__status,
127                                 int __flag, struct FTW *__info);
128 # endif
129 #endif
130
131 #ifdef __UCLIBC_HAS_FTW__
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.  */
136 # ifndef __USE_FILE_OFFSET64
137 extern int ftw (const char *__dir, __ftw_func_t __func, int __descriptors)
138      __nonnull ((1, 2));
139 # else
140 #  ifdef __REDIRECT
141 extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func,
142                              int __descriptors), ftw64) __nonnull ((1, 2));
143 #  else
144 #   define ftw ftw64
145 #  endif
146 # endif
147 # ifdef __USE_LARGEFILE64
148 extern int ftw64 (const char *__dir, __ftw64_func_t __func,
149                   int __descriptors) __nonnull ((1, 2));
150 # endif
151 #endif
152
153 #if defined __UCLIBC_HAS_NFTW__ && defined __USE_XOPEN_EXTENDED
154 /* Call a function on every element in a directory tree.  FLAG allows
155    to specify the behaviour more detailed.
156
157    This function is a possible cancellation point and therefore not
158    marked with __THROW.  */
159 # ifndef __USE_FILE_OFFSET64
160 extern int nftw (const char *__dir, __nftw_func_t __func, int __descriptors,
161                  int __flag) __nonnull ((1, 2));
162 # else
163 #  ifdef __REDIRECT
164 extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func,
165                               int __descriptors, int __flag), nftw64)
166      __nonnull ((1, 2));
167 #  else
168 #   define nftw nftw64
169 #  endif
170 # endif
171 # ifdef __USE_LARGEFILE64
172 extern int nftw64 (const char *__dir, __nftw64_func_t __func,
173                    int __descriptors, int __flag) __nonnull ((1, 2));
174 # endif
175 #endif
176
177 __END_DECLS
178
179 #endif  /* ftw.h */