a51526d4694eb4eecaf131d931fb08c1a31bee2e
[musl] / include / dirent.h
1 #ifndef _DIRENT_H
2 #define _DIRENT_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #define __NEED_ino_t
9 #define __NEED_off_t
10
11 #include <bits/alltypes.h>
12
13 typedef struct __DIR_s DIR;
14
15 struct dirent
16 {
17         ino_t d_ino;
18         off_t d_off;
19         unsigned short d_reclen;
20         unsigned char d_type;
21         char d_name[256];
22 };
23
24 #define d_fileno d_ino
25
26 int            closedir(DIR *);
27 DIR           *fdopendir(int);
28 DIR           *opendir(const char *);
29 struct dirent *readdir(DIR *);
30 int            readdir_r(DIR *, struct dirent *, struct dirent **);
31 void           rewinddir(DIR *);
32 void           seekdir(DIR *, long);
33 long           telldir(DIR *);
34 int            dirfd(DIR *);
35
36 int alphasort(const struct dirent **, const struct dirent **);
37 int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
38
39 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
40 #define DT_UNKNOWN 0
41 #define DT_FIFO 1
42 #define DT_CHR 2
43 #define DT_DIR 4
44 #define DT_BLK 6
45 #define DT_REG 8
46 #define DT_LNK 10
47 #define DT_SOCK 12
48 #define DT_WHT 14
49 #define IFTODT(x) ((x)>>12 & 017)
50 #define DTTOIF(x) ((x)<<12)
51 #endif
52
53 #ifdef _GNU_SOURCE
54 int versionsort(const struct dirent **, const struct dirent **);
55 #endif
56
57 #ifdef _BSD_SOURCE
58 int getdents(int, struct dirent *, size_t);
59 #endif
60
61 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
62 #define dirent64 dirent
63 #define readdir64 readdir
64 #define readdir64_r readdir_r
65 #define scandir64 scandir
66 #define alphasort64 alphasort
67 #define versionsort64 versionsort
68 #define off64_t off_t
69 #define ino64_t ino_t
70 #ifdef _BSD_SOURCE
71 #define getdents64 getdents
72 #endif
73 #endif
74
75 #ifdef __cplusplus
76 }
77 #endif
78
79 #endif