lib	opendir
hdr	dirent,ndir
sys	dir
nxt	dirent

if ( ! _lib_opendir ) {
	/*
	 * <dirent.h> for systems with no opendir()
	 */

	#ifndef _DIRENT_H
	#define _DIRENT_H

	typedef struct
	{
		int		dd_fd;		/* file descriptor		*/
	#ifdef _DIR_PRIVATE_
		_DIR_PRIVATE_
	#endif
	} DIR;

	struct dirent
	{
		long		d_fileno;	/* entry serial number		*/
		int		d_reclen;	/* entry length			*/
		int		d_namlen;	/* entry name length		*/
		char		d_name[1];	/* entry name			*/
	};

	#ifndef _DIR_PRIVATE_

	#ifdef	rewinddir
	#undef	rewinddir
	#define rewinddir(p)	seekdir(p,0L)
	#endif

	extern DIR*		opendir(const char*);
	extern void		closedir(DIR*);
	extern struct dirent*	readdir(DIR*);
	extern void		seekdir(DIR*, long);
	extern long		telldir(DIR*);

	#endif

	#endif
}
elif ( _nxt_dirent && _hdr_dirent ) pass{
cat <<!
	/*
	 * <dirent.h> for systems with ok <dirent.h>
	 */

	#ifndef _DIRENT_H

	#include ${_nxt_dirent-_nxt_dirent}	/* the native <dirent.h> */

	#ifndef _DIRENT_H
	#define _DIRENT_H
	#endif

	#endif
!
}end
elif ( _hdr_ndir ) {
	/*
	 * <dirent.h> for systems with opendir() and <ndir.h>
	 */

	#ifndef _DIRENT_H
	#define _DIRENT_H

	#define closedir	______closedir
	#define opendir		______opendir
	#define readdir		______readdir
	#define seekdir		______seekdir
	#define telldir		______telldir

	#include <ndir.h>

	#undef	closedir
	#undef	opendir
	#undef	readdir
	#undef	seekdir
	#undef	telldir

	#ifndef dirent
	#define dirent	direct
	#endif

	#if !defined(d_fileno) && !defined(d_ino)
	#define d_fileno	d_ino
	#endif

	#ifdef	rewinddir
	#undef	rewinddir
	#define rewinddir(p)	seekdir(p,0L)
	#endif

	extern DIR*		opendir(const char*);
	extern void		closedir(DIR*);
	extern struct dirent*	readdir(DIR*);
	extern void		seekdir(DIR*, long);
	extern long		telldir(DIR*);

	#endif
}
elif ( _sys_dir ) {
	/*
	 * <dirent.h> for systems with opendir() and no <ndir.h>
	 */

	#ifndef _DIRENT_H
	#define _DIRENT_H

	#define closedir	______closedir
	#define opendir		______opendir
	#define readdir		______readdir
	#define seekdir		______seekdir
	#define telldir		______telldir

	#include <sys/dir.h>

	#undef	closedir
	#undef	opendir
	#undef	readdir
	#undef	seekdir
	#undef	telldir

	#ifndef dirent
	#define dirent	direct
	#endif

	#if !defined(d_fileno) && !defined(d_ino)
	#define d_fileno	d_ino
	#endif

	#ifdef	rewinddir
	#undef	rewinddir
	#define rewinddir(p)	seekdir(p,0L)
	#endif

	extern DIR*		opendir(const char*);
	extern void		closedir(DIR*);
	extern struct dirent*	readdir(DIR*);
	extern void		seekdir(DIR*, long);
	extern long		telldir(DIR*);

	#endif
}
endif
