]> git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/include/dirent.h
Fix _DIRENT_HAVE_D_* macros.
[wasi-libc.git] / libc-top-half / musl / include / dirent.h
1 #ifndef _DIRENT_H
2 #define _DIRENT_H
3
4 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5 #else
6 #include <__header_dirent.h>
7 #endif
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #include <features.h>
13
14 #define __NEED_ino_t
15 #define __NEED_off_t
16 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
17 #define __NEED_size_t
18 #endif
19
20 #include <bits/alltypes.h>
21
22 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
23 typedef struct __dirstream DIR;
24 #else
25 #include <__typedef_DIR.h>
26 #endif
27
28 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
29 #define _DIRENT_HAVE_D_RECLEN
30 #define _DIRENT_HAVE_D_OFF
31 #define _DIRENT_HAVE_D_TYPE
32
33 struct dirent {
34 ino_t d_ino;
35 off_t d_off;
36 unsigned short d_reclen;
37 unsigned char d_type;
38 char d_name[256];
39 };
40 #else
41 #include <__struct_dirent.h>
42 #endif
43
44 #define d_fileno d_ino
45
46 int closedir(DIR *);
47 DIR *fdopendir(int);
48 DIR *opendir(const char *);
49 struct dirent *readdir(DIR *);
50 #ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */
51 int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
52 #endif
53 void rewinddir(DIR *);
54 int dirfd(DIR *);
55
56 int alphasort(const struct dirent **, const struct dirent **);
57 int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
58
59 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
60 void seekdir(DIR *, long);
61 long telldir(DIR *);
62 #endif
63
64 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
65 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
66 #define DT_UNKNOWN 0
67 #define DT_FIFO 1
68 #define DT_CHR 2
69 #define DT_DIR 4
70 #define DT_BLK 6
71 #define DT_REG 8
72 #define DT_LNK 10
73 #define DT_SOCK 12
74 #define DT_WHT 14
75 #define IFTODT(x) ((x)>>12 & 017)
76 #define DTTOIF(x) ((x)<<12)
77 #endif
78 int getdents(int, struct dirent *, size_t);
79 #endif
80
81 #ifdef _GNU_SOURCE
82 int versionsort(const struct dirent **, const struct dirent **);
83 #endif
84
85 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
86 #define dirent64 dirent
87 #define readdir64 readdir
88 #define readdir64_r readdir_r
89 #define scandir64 scandir
90 #define alphasort64 alphasort
91 #define versionsort64 versionsort
92 #define off64_t off_t
93 #define ino64_t ino_t
94 #define getdents64 getdents
95 #endif
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #endif