MCPcopy Create free account
hub / github.com/GJDuck/e9patch / fdopen

Function fdopen

examples/stdlib.c:3255–3272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3253}
3254
3255static 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
3274static FILE *fopen(const char *path, const char *mode)
3275{

Callers 2

test_stdioFunction · 0.85
spawnBackendFunction · 0.85

Calls 3

stdio_parse_modeFunction · 0.85
stdio_stream_allocFunction · 0.85
closeFunction · 0.85

Tested by 1

test_stdioFunction · 0.68