xref: /dflybsd-src/contrib/gdb-7/readline/posixdir.h (revision 16003dcfd2baa152f5dd24794ec9f36e139eaeb8)
1*6b445a62SJohn Marino /* posixdir.h -- Posix directory reading includes and defines. */
2*6b445a62SJohn Marino 
3*6b445a62SJohn Marino /* Copyright (C) 1987,1991 Free Software Foundation, Inc.
4*6b445a62SJohn Marino 
5*6b445a62SJohn Marino    This file is part of GNU Bash, the Bourne Again SHell.
6*6b445a62SJohn Marino 
7*6b445a62SJohn Marino    Bash is free software: you can redistribute it and/or modify
8*6b445a62SJohn Marino    it under the terms of the GNU General Public License as published by
9*6b445a62SJohn Marino    the Free Software Foundation, either version 3 of the License, or
10*6b445a62SJohn Marino    (at your option) any later version.
11*6b445a62SJohn Marino 
12*6b445a62SJohn Marino    Bash is distributed in the hope that it will be useful,
13*6b445a62SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*6b445a62SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*6b445a62SJohn Marino    GNU General Public License for more details.
16*6b445a62SJohn Marino 
17*6b445a62SJohn Marino    You should have received a copy of the GNU General Public License
18*6b445a62SJohn Marino    along with Bash.  If not, see <http://www.gnu.org/licenses/>.
19*6b445a62SJohn Marino */
20*6b445a62SJohn Marino 
21*6b445a62SJohn Marino /* This file should be included instead of <dirent.h> or <sys/dir.h>. */
22*6b445a62SJohn Marino 
23*6b445a62SJohn Marino #if !defined (_POSIXDIR_H_)
24*6b445a62SJohn Marino #define _POSIXDIR_H_
25*6b445a62SJohn Marino 
26*6b445a62SJohn Marino #if defined (HAVE_DIRENT_H)
27*6b445a62SJohn Marino #  include <dirent.h>
28*6b445a62SJohn Marino #  if defined (HAVE_STRUCT_DIRENT_D_NAMLEN)
29*6b445a62SJohn Marino #    define D_NAMLEN(d)	((d)->d_namlen)
30*6b445a62SJohn Marino #  else
31*6b445a62SJohn Marino #    define D_NAMLEN(d)   (strlen ((d)->d_name))
32*6b445a62SJohn Marino #  endif /* !HAVE_STRUCT_DIRENT_D_NAMLEN */
33*6b445a62SJohn Marino #else
34*6b445a62SJohn Marino #  if defined (HAVE_SYS_NDIR_H)
35*6b445a62SJohn Marino #    include <sys/ndir.h>
36*6b445a62SJohn Marino #  endif
37*6b445a62SJohn Marino #  if defined (HAVE_SYS_DIR_H)
38*6b445a62SJohn Marino #    include <sys/dir.h>
39*6b445a62SJohn Marino #  endif
40*6b445a62SJohn Marino #  if defined (HAVE_NDIR_H)
41*6b445a62SJohn Marino #    include <ndir.h>
42*6b445a62SJohn Marino #  endif
43*6b445a62SJohn Marino #  if !defined (dirent)
44*6b445a62SJohn Marino #    define dirent direct
45*6b445a62SJohn Marino #  endif /* !dirent */
46*6b445a62SJohn Marino #  define D_NAMLEN(d)   ((d)->d_namlen)
47*6b445a62SJohn Marino #endif /* !HAVE_DIRENT_H */
48*6b445a62SJohn Marino 
49*6b445a62SJohn Marino #if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (HAVE_STRUCT_DIRENT_D_FILENO)
50*6b445a62SJohn Marino #  define d_fileno d_ino
51*6b445a62SJohn Marino #endif
52*6b445a62SJohn Marino 
53*6b445a62SJohn Marino #if defined (_POSIX_SOURCE) && (!defined (HAVE_STRUCT_DIRENT_D_INO) || defined (BROKEN_DIRENT_D_INO))
54*6b445a62SJohn Marino /* Posix does not require that the d_ino field be present, and some
55*6b445a62SJohn Marino    systems do not provide it. */
56*6b445a62SJohn Marino #  define REAL_DIR_ENTRY(dp) 1
57*6b445a62SJohn Marino #else
58*6b445a62SJohn Marino #  define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
59*6b445a62SJohn Marino #endif /* _POSIX_SOURCE */
60*6b445a62SJohn Marino 
61*6b445a62SJohn Marino #endif /* !_POSIXDIR_H_ */
62