add EX__MAX to represent top value listed
[unix-history] / usr / src / include / dirent.h
CommitLineData
63174302 1/*-
2ebafe45
KM
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
63174302 5 * %sccs.include.redist.c%
2ebafe45 6 *
ac8d189a 7 * @(#)dirent.h 5.14 (Berkeley) %G%
2ebafe45
KM
8 */
9
5eb1d172
KM
10#ifndef _DIRENT_
11#define _DIRENT_
12
2ebafe45 13/*
63174302
KB
14 * A directory entry has a struct direct at the front of it, containing its
15 * inode number, the length of the entry, and the length of the name
16 * contained in the entry. These are followed by the name padded to a 4
17 * byte boundary with null bytes. All names are guaranteed null terminated.
18 * The maximum length of a name in a directory is MAXNAMLEN.
2ebafe45 19 */
2ebafe45 20
63174302 21struct dirent {
5eb1d172 22 u_long d_fileno; /* file number of entry */
2ebafe45
KM
23 u_short d_reclen; /* length of this record */
24 u_short d_namlen; /* length of string in d_name */
63174302
KB
25#ifdef _POSIX_SOURCE
26 char d_name[255 + 1]; /* name must be no longer than this */
27#else
28#define MAXNAMLEN 255
2ebafe45 29 char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
63174302 30#endif
2ebafe45
KM
31};
32
63174302
KB
33#ifdef _POSIX_SOURCE
34typedef void * DIR;
35#else
36
37#define d_ino d_fileno /* backward compatibility */
38
39/* definitions for library routines operating on directories. */
53a35811 40#define DIRBLKSIZ 1024
2ebafe45 41
63174302 42/* structure describing an open directory. */
2ebafe45 43typedef struct _dirdesc {
514b4877
KM
44 int dd_fd; /* file descriptor associated with directory */
45 long dd_loc; /* offset in current buffer */
46 long dd_size; /* amount of data returned by getdirentries */
47 char *dd_buf; /* data buffer */
48 int dd_len; /* size of data buffer */
49 long dd_seek; /* magic cookie returned by getdirentries */
2ebafe45
KM
50} DIR;
51
63174302 52#define dirfd(dirp) ((dirp)->dd_fd)
2ebafe45
KM
53
54#ifndef NULL
63174302 55#define NULL 0
2ebafe45 56#endif
e7ce7d7c 57
63174302 58#endif /* _POSIX_SOURCE */
e7ce7d7c 59
6670c0eb 60#if __STDC__ || c_plusplus
e7ce7d7c
KB
61extern DIR *opendir(const char *);
62extern struct dirent *readdir(DIR *);
45d27b3d 63extern void rewinddir(DIR *);
63174302
KB
64extern int closedir(DIR *);
65#ifndef _POSIX_SOURCE
e7ce7d7c
KB
66extern long telldir(const DIR *);
67extern void seekdir(DIR *, long);
ac8d189a
KB
68extern int scandir(const char *, struct dirent ***,
69 int (*)(struct dirent *), int (*)(void *, void *));
8ac81353 70extern int alphasort(const void *, const void *);
63174302 71#endif
e7ce7d7c
KB
72#else
73extern DIR *opendir();
74extern struct dirent *readdir();
63174302
KB
75extern void rewinddir();
76extern int closedir();
77#ifndef _POSIX_SOURCE
e7ce7d7c
KB
78extern long telldir();
79extern void seekdir();
e7ce7d7c
KB
80extern int scandir();
81extern int alphasort();
82#endif
63174302 83#endif
5eb1d172 84#endif /* _DIRENT_ */