blob: c0e3492b9cdc66b612adcfac28409468ef81b7f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "stddef.h" // for NULL
#include <__dirent.h> // for __DIR
#include <dirent.h> // for DIR, fdopendir
#include <errno.h> // for EBADF, errno
#include <stdlib.h> // for calloc
DIR *fdopendir(int fildes)
{
struct __DIR *dir;
if (fildes < 0) {
errno = EBADF;
return NULL;
}
if ((dir = calloc(1, sizeof(struct __DIR))) == NULL) {
return NULL;
}
dir->fildes = fildes;
return dir;
}
|