Blame lib/dirent.in.h

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