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