2 * Acess2 POSIX Emulation Library
3 * - By John Hodge (thePowersGang)
6 * - File descriptor control
8 #include <sys/types.h> // off_t
12 #include <acess/sys.h>
16 int fcntl(int fd, int cmd, ...)
25 int a_flags = _SysFDFlags(fd, 0, 0);
29 if(a_flags & OPENFLAG_READ) ret |= O_RDONLY;
30 if(a_flags & OPENFLAG_WRITE) ret |= O_WRONLY;
31 if(a_flags & OPENFLAG_NONBLOCK) ret |= O_NONBLOCK;
32 if(a_flags & OPENFLAG_APPEND) ret |= O_APPEND;
33 // TODO: Extra flags for F_GETFL
36 long p_flags = va_arg(args, long);
38 const int mask = OPENFLAG_NONBLOCK|OPENFLAG_APPEND;
40 if(p_flags & O_NONBLOCK)
41 a_flags |= OPENFLAG_NONBLOCK;
42 if(p_flags & O_APPEND)
43 a_flags |= OPENFLAG_APPEND;
44 // TODO: Extra flags for F_SETFL
46 ret = _SysFDFlags(fd, mask, a_flags);
47 _SysDebug("fcntl(%i, F_SETFL, 0x%lx) = Acess 0x%x", fd, p_flags, ret);
53 _SysDebug("fcntl(%i) unknown or unimplimented", cmd);