Blame lib/dirent.in.h

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