Blame lib/dirent.in.h

Packit 709fb3
/* A GNU-like <dirent.h>.
Packit 709fb3
   Copyright (C) 2006-2017 Free Software Foundation, Inc.
Packit 709fb3
Packit 709fb3
   This program is free software: you can redistribute it and/or modify
Packit 709fb3
   it under the terms of the GNU General Public License as published by
Packit 709fb3
   the Free Software Foundation; either version 3 of the License, or
Packit 709fb3
   (at your option) any later version.
Packit 709fb3
Packit 709fb3
   This program is distributed in the hope that it will be useful,
Packit 709fb3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 709fb3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 709fb3
   GNU General Public License for more details.
Packit 709fb3
Packit 709fb3
   You should have received a copy of the GNU General Public License
Packit 709fb3
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 709fb3
Packit 709fb3
#ifndef _@GUARD_PREFIX@_DIRENT_H
Packit 709fb3
Packit 709fb3
#if __GNUC__ >= 3
Packit 709fb3
@PRAGMA_SYSTEM_HEADER@
Packit 709fb3
#endif
Packit 709fb3
@PRAGMA_COLUMNS@
Packit 709fb3
Packit 709fb3
/* The include_next requires a split double-inclusion guard.  */
Packit 709fb3
#if @HAVE_DIRENT_H@
Packit 709fb3
# @INCLUDE_NEXT@ @NEXT_DIRENT_H@
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#ifndef _@GUARD_PREFIX@_DIRENT_H
Packit 709fb3
#define _@GUARD_PREFIX@_DIRENT_H
Packit 709fb3
Packit 709fb3
/* Get ino_t.  Needed on some systems, including glibc 2.8.  */
Packit 709fb3
#include <sys/types.h>
Packit 709fb3
Packit 709fb3
#if !@HAVE_DIRENT_H@
Packit 709fb3
/* Define types DIR and 'struct dirent'.  */
Packit 709fb3
# if !GNULIB_defined_struct_dirent
Packit 709fb3
struct dirent
Packit 709fb3
{
Packit 709fb3
  char d_type;
Packit 709fb3
  char d_name[1];
Packit 709fb3
};
Packit 709fb3
/* Possible values for 'd_type'.  */
Packit 709fb3
#  define DT_UNKNOWN 0
Packit 709fb3
#  define DT_FIFO    1          /* FIFO */
Packit 709fb3
#  define DT_CHR     2          /* character device */
Packit 709fb3
#  define DT_DIR     4          /* directory */
Packit 709fb3
#  define DT_BLK     6          /* block device */
Packit 709fb3
#  define DT_REG     8          /* regular file */
Packit 709fb3
#  define DT_LNK    10          /* symbolic link */
Packit 709fb3
#  define DT_SOCK   12          /* socket */
Packit 709fb3
#  define DT_WHT    14          /* whiteout */
Packit 709fb3
typedef struct gl_directory DIR;
Packit 709fb3
#  define GNULIB_defined_struct_dirent 1
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
/* The __attribute__ feature is available in gcc versions 2.5 and later.
Packit 709fb3
   The attribute __pure__ was added in gcc 2.96.  */
Packit 709fb3
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
Packit 709fb3
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
Packit 709fb3
#else
Packit 709fb3
# define _GL_ATTRIBUTE_PURE /* empty */
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
Packit 709fb3
Packit 709fb3
/* The definition of _GL_ARG_NONNULL is copied here.  */
Packit 709fb3
Packit 709fb3
/* The definition of _GL_WARN_ON_USE is copied here.  */
Packit 709fb3
Packit 709fb3
Packit 709fb3
/* Declare overridden functions.  */
Packit 709fb3
Packit 709fb3
#if @GNULIB_OPENDIR@
Packit 709fb3
# if @REPLACE_OPENDIR@
Packit 709fb3
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 709fb3
#   undef opendir
Packit 709fb3
#   define opendir rpl_opendir
Packit 709fb3
#   define GNULIB_defined_opendir 1
Packit 709fb3
#  endif
Packit 709fb3
_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
Packit 709fb3
_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
Packit 709fb3
# else
Packit 709fb3
#  if !@HAVE_OPENDIR@
Packit 709fb3
_GL_FUNCDECL_SYS (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
Packit 709fb3
#  endif
Packit 709fb3
_GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
Packit 709fb3
# endif
Packit 709fb3
_GL_CXXALIASWARN (opendir);
Packit 709fb3
#elif defined GNULIB_POSIXCHECK
Packit 709fb3
# undef opendir
Packit 709fb3
# if HAVE_RAW_DECL_OPENDIR
Packit 709fb3
_GL_WARN_ON_USE (opendir, "opendir is not portable - "
Packit 709fb3
                 "use gnulib module opendir for portability");
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if @GNULIB_READDIR@
Packit 709fb3
# if !@HAVE_READDIR@
Packit 709fb3
_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
Packit 709fb3
# endif
Packit 709fb3
_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
Packit 709fb3
_GL_CXXALIASWARN (readdir);
Packit 709fb3
#elif defined GNULIB_POSIXCHECK
Packit 709fb3
# undef readdir
Packit 709fb3
# if HAVE_RAW_DECL_READDIR
Packit 709fb3
_GL_WARN_ON_USE (readdir, "readdir is not portable - "
Packit 709fb3
                 "use gnulib module readdir for portability");
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if @GNULIB_REWINDDIR@
Packit 709fb3
# if !@HAVE_REWINDDIR@
Packit 709fb3
_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
Packit 709fb3
# endif
Packit 709fb3
_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
Packit 709fb3
_GL_CXXALIASWARN (rewinddir);
Packit 709fb3
#elif defined GNULIB_POSIXCHECK
Packit 709fb3
# undef rewinddir
Packit 709fb3
# if HAVE_RAW_DECL_REWINDDIR
Packit 709fb3
_GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
Packit 709fb3
                 "use gnulib module rewinddir for portability");
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if @GNULIB_CLOSEDIR@
Packit 709fb3
# if @REPLACE_CLOSEDIR@
Packit 709fb3
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 709fb3
#   undef closedir
Packit 709fb3
#   define closedir rpl_closedir
Packit 709fb3
#   define GNULIB_defined_closedir 1
Packit 709fb3
#  endif
Packit 709fb3
_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
Packit 709fb3
_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
Packit 709fb3
# else
Packit 709fb3
#  if !@HAVE_CLOSEDIR@
Packit 709fb3
_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
Packit 709fb3
#  endif
Packit 709fb3
_GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
Packit 709fb3
# endif
Packit 709fb3
_GL_CXXALIASWARN (closedir);
Packit 709fb3
#elif defined GNULIB_POSIXCHECK
Packit 709fb3
# undef closedir
Packit 709fb3
# if HAVE_RAW_DECL_CLOSEDIR
Packit 709fb3
_GL_WARN_ON_USE (closedir, "closedir is not portable - "
Packit 709fb3
                 "use gnulib module closedir for portability");
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if @GNULIB_DIRFD@
Packit 709fb3
/* Return the file descriptor associated with the given directory stream,
Packit 709fb3
   or -1 if none exists.  */
Packit 709fb3
# if @REPLACE_DIRFD@
Packit 709fb3
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 709fb3
#   undef dirfd
Packit 709fb3
#   define dirfd rpl_dirfd
Packit 709fb3
#  endif
Packit 709fb3
_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
Packit 709fb3
_GL_CXXALIAS_RPL (dirfd, int, (DIR *));
Packit 709fb3
Packit 709fb3
#  ifdef __KLIBC__
Packit 709fb3
/* Gnulib internal hooks needed to maintain the dirfd metadata.  */
Packit 709fb3
_GL_EXTERN_C int _gl_register_dirp_fd (int fd, DIR *dirp)
Packit 709fb3
     _GL_ARG_NONNULL ((2));
Packit 709fb3
_GL_EXTERN_C void _gl_unregister_dirp_fd (int fd);
Packit 709fb3
#  endif
Packit 709fb3
# else
Packit 709fb3
#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
Packit 709fb3
    /* dirfd is defined as a macro and not as a function.
Packit 709fb3
       Turn it into a function and get rid of the macro.  */
Packit 709fb3
static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
Packit 709fb3
#   undef dirfd
Packit 709fb3
#  endif
Packit 709fb3
#  if !(@HAVE_DECL_DIRFD@ || defined dirfd)
Packit 709fb3
_GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
Packit 709fb3
#  endif
Packit 709fb3
_GL_CXXALIAS_SYS (dirfd, int, (DIR *));
Packit 709fb3
# endif
Packit 709fb3
_GL_CXXALIASWARN (dirfd);
Packit 709fb3
#elif defined GNULIB_POSIXCHECK
Packit 709fb3
# undef dirfd
Packit 709fb3
# if HAVE_RAW_DECL_DIRFD
Packit 709fb3
_GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
Packit 709fb3
                 "use gnulib module dirfd for portability");
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if @GNULIB_FDOPENDIR@
Packit 709fb3
/* Open a directory stream visiting the given directory file
Packit 709fb3
   descriptor.  Return NULL and set errno if fd is not visiting a
Packit 709fb3
   directory.  On success, this function consumes fd (it will be
Packit 709fb3
   implicitly closed either by this function or by a subsequent
Packit 709fb3
   closedir).  */
Packit 709fb3
# if @REPLACE_FDOPENDIR@
Packit 709fb3
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 709fb3
#   undef fdopendir
Packit 709fb3
#   define fdopendir rpl_fdopendir
Packit 709fb3
#  endif
Packit 709fb3
_GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
Packit 709fb3
_GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
Packit 709fb3
# else
Packit 709fb3
#  if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@
Packit 709fb3
_GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
Packit 709fb3
#  endif
Packit 709fb3
_GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
Packit 709fb3
# endif
Packit 709fb3
_GL_CXXALIASWARN (fdopendir);
Packit 709fb3
#elif defined GNULIB_POSIXCHECK
Packit 709fb3
# undef fdopendir
Packit 709fb3
# if HAVE_RAW_DECL_FDOPENDIR
Packit 709fb3
_GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
Packit 709fb3
                 "use gnulib module fdopendir for portability");
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if @GNULIB_SCANDIR@
Packit 709fb3
/* Scan the directory DIR, calling FILTER on each directory entry.
Packit 709fb3
   Entries for which FILTER returns nonzero are individually malloc'd,
Packit 709fb3
   sorted using qsort with CMP, and collected in a malloc'd array in
Packit 709fb3
   *NAMELIST.  Returns the number of entries selected, or -1 on error.  */
Packit 709fb3
# if !@HAVE_SCANDIR@
Packit 709fb3
_GL_FUNCDECL_SYS (scandir, int,
Packit 709fb3
                  (const char *dir, struct dirent ***namelist,
Packit 709fb3
                   int (*filter) (const struct dirent *),
Packit 709fb3
                   int (*cmp) (const struct dirent **, const struct dirent **))
Packit 709fb3
                  _GL_ARG_NONNULL ((1, 2, 4)));
Packit 709fb3
# endif
Packit 709fb3
/* Need to cast, because on glibc systems, the fourth parameter is
Packit 709fb3
                        int (*cmp) (const void *, const void *).  */
Packit 709fb3
_GL_CXXALIAS_SYS_CAST (scandir, int,
Packit 709fb3
                       (const char *dir, struct dirent ***namelist,
Packit 709fb3
                        int (*filter) (const struct dirent *),
Packit 709fb3
                        int (*cmp) (const struct dirent **, const struct dirent **)));
Packit 709fb3
_GL_CXXALIASWARN (scandir);
Packit 709fb3
#elif defined GNULIB_POSIXCHECK
Packit 709fb3
# undef scandir
Packit 709fb3
# if HAVE_RAW_DECL_SCANDIR
Packit 709fb3
_GL_WARN_ON_USE (scandir, "scandir is unportable - "
Packit 709fb3
                 "use gnulib module scandir for portability");
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if @GNULIB_ALPHASORT@
Packit 709fb3
/* Compare two 'struct dirent' entries alphabetically.  */
Packit 709fb3
# if !@HAVE_ALPHASORT@
Packit 709fb3
_GL_FUNCDECL_SYS (alphasort, int,
Packit 709fb3
                  (const struct dirent **, const struct dirent **)
Packit 709fb3
                  _GL_ATTRIBUTE_PURE
Packit 709fb3
                  _GL_ARG_NONNULL ((1, 2)));
Packit 709fb3
# endif
Packit 709fb3
/* Need to cast, because on glibc systems, the parameters are
Packit 709fb3
                       (const void *, const void *).  */
Packit 709fb3
_GL_CXXALIAS_SYS_CAST (alphasort, int,
Packit 709fb3
                       (const struct dirent **, const struct dirent **));
Packit 709fb3
_GL_CXXALIASWARN (alphasort);
Packit 709fb3
#elif defined GNULIB_POSIXCHECK
Packit 709fb3
# undef alphasort
Packit 709fb3
# if HAVE_RAW_DECL_ALPHASORT
Packit 709fb3
_GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
Packit 709fb3
                 "use gnulib module alphasort for portability");
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
Packit 709fb3
#endif /* _@GUARD_PREFIX@_DIRENT_H */
Packit 709fb3
#endif /* _@GUARD_PREFIX@_DIRENT_H */