121308Sache/* posixdir.h -- Posix directory reading includes and defines. */
221308Sache
321308Sache/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
421308Sache
521308Sache   This file is part of GNU Bash, the Bourne Again SHell.
621308Sache
721308Sache   Bash is free software; you can redistribute it and/or modify it
821308Sache   under the terms of the GNU General Public License as published by
958310Sache   the Free Software Foundation; either version 2, or (at your option)
1021308Sache   any later version.
1121308Sache
1221308Sache   Bash is distributed in the hope that it will be useful, but WITHOUT
1321308Sache   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1421308Sache   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
1521308Sache   License for more details.
1621308Sache
1721308Sache   You should have received a copy of the GNU General Public License
1821308Sache   along with Bash; see the file COPYING.  If not, write to the Free
1958310Sache   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
2021308Sache
2121308Sache/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
2221308Sache
2321308Sache#if !defined (_POSIXDIR_H_)
2421308Sache#define _POSIXDIR_H_
2521308Sache
2621308Sache#if defined (HAVE_DIRENT_H)
2721308Sache#  include <dirent.h>
28136644Sache#  if defined (HAVE_STRUCT_DIRENT_D_NAMLEN)
29136644Sache#    define D_NAMLEN(d)	((d)->d_namlen)
30136644Sache#  else
31136644Sache#    define D_NAMLEN(d)   (strlen ((d)->d_name))
32136644Sache#  endif /* !HAVE_STRUCT_DIRENT_D_NAMLEN */
3321308Sache#else
3421308Sache#  if defined (HAVE_SYS_NDIR_H)
3521308Sache#    include <sys/ndir.h>
3621308Sache#  endif
3721308Sache#  if defined (HAVE_SYS_DIR_H)
3821308Sache#    include <sys/dir.h>
3921308Sache#  endif
4021308Sache#  if defined (HAVE_NDIR_H)
4121308Sache#    include <ndir.h>
4221308Sache#  endif
4321308Sache#  if !defined (dirent)
4421308Sache#    define dirent direct
4521308Sache#  endif /* !dirent */
4621308Sache#  define D_NAMLEN(d)   ((d)->d_namlen)
4721308Sache#endif /* !HAVE_DIRENT_H */
4821308Sache
49136644Sache#if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (HAVE_STRUCT_DIRENT_D_FILENO)
5021308Sache#  define d_fileno d_ino
5121308Sache#endif
5221308Sache
53136644Sache#if defined (_POSIX_SOURCE) && (!defined (HAVE_STRUCT_DIRENT_D_INO) || defined (BROKEN_DIRENT_D_INO))
54119610Sache/* Posix does not require that the d_ino field be present, and some
55119610Sache   systems do not provide it. */
56119610Sache#  define REAL_DIR_ENTRY(dp) 1
57119610Sache#else
58119610Sache#  define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
59119610Sache#endif /* _POSIX_SOURCE */
60119610Sache
6121308Sache#endif /* !_POSIXDIR_H_ */
62