]> git.ipfire.org Git - thirdparty/glibc.git/blame - io/ftw.h
Update.
[thirdparty/glibc.git] / io / ftw.h
CommitLineData
df4ef2ab 1/* Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc.
54d79e99 2 This file is part of the GNU C Library.
28f540f4 3
54d79e99
UD
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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
12 Library General Public License for more details.
28f540f4 13
54d79e99
UD
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 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
24
25#define _FTW_H 1
26#include <features.h>
27
76b87c03 28#include <sys/types.h>
28f540f4
RM
29#include <statbuf.h>
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'. */
36enum
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
47#ifdef __USE_XOPEN_EXTENDED
48
49 FTW_SL, /* Symbolic link. */
50# define FTW_SL FTW_SL
51
52/* These flags are only passed from the `nftw' function. */
53 FTW_DP, /* Directory, all subdirs have been visited. */
54# define FTW_DP FTW_DP
55 FTW_SLN /* Symbolic link naming non-existing file. */
56# define FTW_SLN FTW_SLN
57
58#endif /* extended X/Open */
59};
60
61
62#ifdef __USE_XOPEN_EXTENDED
63/* Flags for fourth argument of `nftw'. */
64enum
65{
66 FTW_PHYS = 1, /* Perform physical walk, ignore symlinks. */
67# define FTW_PHYS FTW_PHYS
68 FTW_MOUNT = 2, /* Report only files on same file system as the
69 argument. */
70# define FTW_MOUNT FTW_MOUNT
71 FTW_CHDIR = 4, /* Change to current directory while processing it. */
72# define FTW_CHDIR FTW_CHDIR
73 FTW_DEPTH = 8 /* Report files in directory before directory itself.*/
74# define FTW_DEPTH FTW_DEPTH
75};
76
77/* Structure used for fourth argument to callback function for `nftw'. */
78struct FTW
79 {
80 int base;
81 int level;
82 };
83#endif /* extended X/Open */
84
85
86/* Convenient types for callback functions. */
87typedef int (*__ftw_func_t) __P ((__const char *filename,
88 __const struct stat *status, int flag));
89#ifdef __USE_XOPEN_EXTENDED
90typedef int (*__nftw_func_t) __P ((__const char *filename,
91 __const struct stat *status, int flag,
92 struct FTW *));
93#endif
94
28f540f4 95/* Call a function on every element in a directory tree. */
76b87c03
UD
96extern int ftw __P ((__const char *dir, __ftw_func_t func, int descriptors));
97
98#ifdef __USE_XOPEN_EXTENDED
99/* Call a function on every element in a directory tree. FLAG allows
100 to specify the behaviour more detailed. */
101extern int nftw __P ((__const char *dir, __nftw_func_t func,
102 int descriptors, int flag));
103#endif
28f540f4 104
1fb05e3d
UD
105__END_DECLS
106
28f540f4 107#endif /* ftw.h */