/*	@(#)dirent.h	1.1 88/02/04 4.0NFSSRC SMI; from SMI 1.2 87/07/14	*/

/* 
 * Copyright (c) 1988 by Sun Microsystems, Inc.
 */

/*
 * Filesystem-independent directory information. 
 */

#ifndef __dirent_h
#define __dirent_h

/*
 * The next definition (in the implementation-reserved namespace) is
 * common to more than one header.  The format of the line must be the
 * same in all cases to keep the compiler quiet.
 */
#define	_NAME_MAX	255

/*
 * Filesystem-independent directory information.  Directory entry
 * structures are of variable length.  Each directory entry is a struct
 * dirent containing its file number, the offset of the next entry (a
 * cookie interpretable only by the filesystem type that generated it),
 * the length of the entry, and the length of the name contained in the
 * entry.  These are followed by the name. The entire entry is padded
 * with null bytes to a 4 byte boundary. All names are guaranteed null
 * terminated. The maximum length of a name in a directory is NAME_MAX
 * plus a null byte.
 */
struct	dirent {
	off_t   d_off;			/* offset of next disk directory entry */
#ifdef	_BSD_C
	u_long	d_fileno;		/* file number of entry */
#define	d_ino	d_fileno		/* for compatibility */
#else
	ino_t	d_ino;
#endif
	u_short	d_reclen;		/* length of this record */
	u_short	d_namlen;		/* length of string in d_name */
	char	d_name[_NAME_MAX + 1];	/* name */
};

#ifndef	_KERNEL
/*
 * Definitions for library routines operating on directories.
 */
typedef struct _dirdesc {
    int	    dd_fd;		/* file descriptor */
    long    dd_loc;		/* buf offset of entry from last readdir() */
    long    dd_size;		/* amount of valid data in buffer */
    long    dd_bsize;		/* amount of entries read at a time */
    long    dd_off;		/* Current offset in dir (for telldir) */
    char    *dd_buf;		/* directory data buffer */
} DIR;

extern DIR *opendir(char * /*dirname*/);
extern struct dirent *readdir(DIR * /*dirp*/);
extern void rewinddir(DIR * /*dirp*/);
#if !defined(_POSIX_SOURCE)
extern long telldir(DIR * /*dirp*/);
extern void seekdir(DIR * /*dirp*/, long /*loc*/);
#endif
extern int closedir(DIR * /*dirp*/);

#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) && !defined(NULL)
#define NULL 0
#endif

#endif/*_KERNEL*/

#if defined(_BSD_C) && !defined(__sys_dirent_h)
#include "sys/dirent.h"
#endif


#endif	/*__dirent_h */

/* EOF dirent.h */
