Commit | Line | Data |
---|---|---|
2ebafe45 KM |
1 | /* |
2 | * Copyright (c) 1989 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that the above copyright notice and this paragraph are | |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
16 | * | |
e7ce7d7c | 17 | * @(#)dirent.h 5.8 (Berkeley) %G% |
2ebafe45 KM |
18 | */ |
19 | ||
5eb1d172 KM |
20 | #ifndef _DIRENT_ |
21 | #define _DIRENT_ | |
22 | ||
2ebafe45 KM |
23 | /* |
24 | * A directory entry has a struct direct at the front of it, | |
25 | * containing its inode number, the length of the entry, and the | |
26 | * length of the name contained in the entry. These are followed | |
27 | * by the name padded to a 4 byte boundary with null bytes. All | |
28 | * names are guaranteed null terminated. The maximum length of a | |
29 | * name in a directory is MAXNAMLEN. | |
30 | */ | |
31 | #define MAXNAMLEN 255 | |
32 | ||
33 | struct dirent { | |
5eb1d172 | 34 | u_long d_fileno; /* file number of entry */ |
2ebafe45 KM |
35 | u_short d_reclen; /* length of this record */ |
36 | u_short d_namlen; /* length of string in d_name */ | |
37 | char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ | |
38 | }; | |
5eb1d172 | 39 | #define d_ino d_fileno /* backward compatibility */ |
2ebafe45 KM |
40 | |
41 | /* | |
42 | * Definitions for library routines operating on directories. | |
43 | */ | |
53a35811 | 44 | #define DIRBLKSIZ 1024 |
2ebafe45 | 45 | |
514b4877 KM |
46 | /* |
47 | * This structure describes an open directory. | |
48 | */ | |
2ebafe45 | 49 | typedef struct _dirdesc { |
514b4877 KM |
50 | int dd_fd; /* file descriptor associated with directory */ |
51 | long dd_loc; /* offset in current buffer */ | |
52 | long dd_size; /* amount of data returned by getdirentries */ | |
53 | char *dd_buf; /* data buffer */ | |
54 | int dd_len; /* size of data buffer */ | |
55 | long dd_seek; /* magic cookie returned by getdirentries */ | |
2ebafe45 KM |
56 | } DIR; |
57 | ||
58 | #define dirfd(dirp) ((dirp)->dd_fd) | |
59 | ||
60 | #ifndef NULL | |
61 | #define NULL 0 | |
62 | #endif | |
e7ce7d7c | 63 | |
b4a8c93b KM |
64 | extern long _rewinddir; |
65 | #define rewinddir(dirp) \ | |
ed3e0baa | 66 | _seekdir((dirp), _rewinddir), \ |
b4a8c93b | 67 | _rewinddir = telldir(dirp) |
e7ce7d7c KB |
68 | |
69 | #ifdef __STDC__ | |
70 | extern DIR *opendir(const char *); | |
71 | extern struct dirent *readdir(DIR *); | |
72 | extern long telldir(const DIR *); | |
73 | extern void seekdir(DIR *, long); | |
74 | extern void closedir(DIR *); | |
75 | extern int scandir(const char *, struct direct *(*[]), | |
76 | int (* )(struct direct *), int (* )(char *, char *)); | |
77 | extern int alphasort(const struct direct **, const struct direct **); | |
78 | #else | |
79 | extern DIR *opendir(); | |
80 | extern struct dirent *readdir(); | |
81 | extern long telldir(); | |
82 | extern void seekdir(); | |
83 | extern void closedir(); | |
84 | extern int scandir(); | |
85 | extern int alphasort(); | |
86 | #endif | |
5eb1d172 | 87 | #endif /* _DIRENT_ */ |