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