ftw.h 4.2 KB

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