| 1 | /*- |
| 2 | * Copyright (c) 1989 The Regents of the University of California. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * %sccs.include.redist.c% |
| 6 | * |
| 7 | * @(#)dirent.h 5.19 (Berkeley) %G% |
| 8 | */ |
| 9 | |
| 10 | #ifndef _DIRENT_H_ |
| 11 | #define _DIRENT_H_ |
| 12 | |
| 13 | /* |
| 14 | * The kernel defines the format of directory entries returned by |
| 15 | * the getdirentries(2) system call. |
| 16 | */ |
| 17 | #include <sys/dirent.h> |
| 18 | |
| 19 | #ifdef _POSIX_SOURCE |
| 20 | typedef void * DIR; |
| 21 | #else |
| 22 | |
| 23 | #define d_ino d_fileno /* backward compatibility */ |
| 24 | |
| 25 | /* definitions for library routines operating on directories. */ |
| 26 | #define DIRBLKSIZ 1024 |
| 27 | |
| 28 | /* structure describing an open directory. */ |
| 29 | typedef struct _dirdesc { |
| 30 | int dd_fd; /* file descriptor associated with directory */ |
| 31 | long dd_loc; /* offset in current buffer */ |
| 32 | long dd_size; /* amount of data returned by getdirentries */ |
| 33 | char *dd_buf; /* data buffer */ |
| 34 | int dd_len; /* size of data buffer */ |
| 35 | long dd_seek; /* magic cookie returned by getdirentries */ |
| 36 | } DIR; |
| 37 | |
| 38 | #define dirfd(dirp) ((dirp)->dd_fd) |
| 39 | |
| 40 | #ifndef NULL |
| 41 | #define NULL 0 |
| 42 | #endif |
| 43 | |
| 44 | #endif /* _POSIX_SOURCE */ |
| 45 | |
| 46 | #ifndef KERNEL |
| 47 | |
| 48 | #include <sys/cdefs.h> |
| 49 | |
| 50 | __BEGIN_DECLS |
| 51 | DIR *opendir __P((const char *)); |
| 52 | struct dirent *readdir __P((DIR *)); |
| 53 | void rewinddir __P((DIR *)); |
| 54 | int closedir __P((DIR *)); |
| 55 | #ifndef _POSIX_SOURCE |
| 56 | long telldir __P((const DIR *)); |
| 57 | void seekdir __P((DIR *, long)); |
| 58 | int scandir __P((const char *, struct dirent ***, |
| 59 | int (*)(struct dirent *), int (*)(const void *, const void *))); |
| 60 | int alphasort __P((const void *, const void *)); |
| 61 | int getdirentries __P((int, char *, int, long *)); |
| 62 | #endif /* not POSIX */ |
| 63 | __END_DECLS |
| 64 | |
| 65 | #endif /* !KERNEL */ |
| 66 | |
| 67 | #endif /* !_DIRENT_H_ */ |