home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / IO / FCNTL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  733 b   |  34 lines

  1. /* fcntl.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <fcntl.h>
  5. #include <errno.h>
  6.  
  7. #define FLAGS (O_APPEND | O_NDELAY)
  8.  
  9. int fcntl (int handle, int request, int arg)
  10. {
  11.   if (handle < 0 || handle >= _nfiles)
  12.     {
  13.       errno = EBADF;
  14.       return (-1);
  15.     }
  16.   switch (request)
  17.     {
  18.     case F_GETFL:
  19.       return (_files[handle] & FLAGS);
  20.     case F_SETFL:
  21.       if (arg & ~FLAGS)
  22.         break;
  23.       if (__fcntl (handle, request, arg) == -1)
  24.         return (-1);
  25.       SETBITS (_files[handle], FLAGS, arg);
  26.       return (0);
  27.     case F_GETFD:
  28.     case F_SETFD:
  29.       return (__fcntl (handle, request, arg));
  30.     }
  31.   errno = EINVAL;
  32.   return (-1);
  33. }
  34.