Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / fcntl.c
blob6d77b68e9217135218802eecf64bb12f6ddafa9d
1 /*
2 * This routine currently offers minimal functionality and was written at
3 * early stage of dhclient porting. Since then dhclient port architecture
4 * was reconsidered and this function was cancelled. If needed it can be
5 * reincarnated in future netlib versions to be fully functional and
6 * usable on any Level-1 file (or socket) descriptor.
7 */
9 #include <errno.h>
10 #include <fcntl.h>
11 #include <sys/filio.h>
12 #include <proto/socket.h>
14 int fcntl(int fd, int cmd, ...)
16 va_list a;
17 int res1, res2;
18 long arg;
19 long nbio = 0;
20 long async = 0;
22 switch (cmd) {
23 case F_SETFL:
24 va_start(a, cmd);
25 arg = va_arg(a, long);
26 va_end(a);
27 if (arg & O_NONBLOCK)
28 nbio = 1;
29 if (arg & O_ASYNC)
30 async = 1;
31 res1 = IoctlSocket(fd, FIONBIO, (char *)&nbio);
32 res2 = IoctlSocket(fd, FIOASYNC, (char *)&async);
33 return (res1 | res2);
34 default:
35 errno = EINVAL;
36 return -1;