ummm, well, we took a vote -- it's a void * agian
[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 *
41c3f8bb 7 * @(#)dirent.h 5.18 (Berkeley) %G%
2ebafe45
KM
8 */
9
91befe9c
KB
10#ifndef _DIRENT_H_
11#define _DIRENT_H_
5eb1d172 12
2ebafe45 13/*
9bfec22c 14 * A directory entry has a struct dirent at the front of it, containing its
63174302
KB
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
5ac3090f
DS
60#ifndef KERNEL
61
91befe9c
KB
62#include <sys/cdefs.h>
63
64__BEGIN_DECLS
65DIR *opendir __P((const char *));
66struct dirent *readdir __P((DIR *));
67void rewinddir __P((DIR *));
68int closedir __P((DIR *));
63174302 69#ifndef _POSIX_SOURCE
91befe9c
KB
70long telldir __P((const DIR *));
71void seekdir __P((DIR *, long));
72int scandir __P((const char *, struct dirent ***,
41c3f8bb 73 int (*)(struct dirent *), int (*)(const void *, const void *)));
91befe9c 74int alphasort __P((const void *, const void *));
5ac3090f
DS
75int getdirentries __P((int, char *, int, long *));
76#endif /* not POSIX */
91befe9c
KB
77__END_DECLS
78
5ac3090f
DS
79#endif /* !KERNEL */
80
91befe9c 81#endif /* !_DIRENT_H_ */