| 3253 | } |
| 3254 | |
| 3255 | static FILE *fdopen(int fd, const char *mode) |
| 3256 | { |
| 3257 | int flags = stdio_parse_mode(mode); |
| 3258 | if (flags < 0) |
| 3259 | { |
| 3260 | errno = EINVAL; |
| 3261 | return NULL; |
| 3262 | } |
| 3263 | bool r = ((flags & O_ACCMODE) != O_WRONLY? true: false); |
| 3264 | bool w = ((flags & O_ACCMODE) != O_RDONLY? true: false); |
| 3265 | FILE *stream = stdio_stream_alloc(fd, r, w, _IOFBF); |
| 3266 | if (stream == NULL) |
| 3267 | { |
| 3268 | close(fd); |
| 3269 | return NULL; |
| 3270 | } |
| 3271 | return stream; |
| 3272 | } |
| 3273 | |
| 3274 | static FILE *fopen(const char *path, const char *mode) |
| 3275 | { |