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

  1. /* setmode.c (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <io.h>
  5. #include <errno.h>
  6. #include <fcntl.h>
  7.  
  8. int setmode (int handle, int mode)
  9. {
  10.   int old_mode;
  11.  
  12.   if (handle < 0 || handle >= _nfiles)
  13.     {
  14.       errno = EBADF;
  15.       return (-1);
  16.     }
  17.   old_mode = ((_files[handle] & O_TEXT) ? O_TEXT : O_BINARY);
  18.   if (mode == O_BINARY)
  19.     _files[handle] &= ~O_TEXT;
  20.   else if (mode == O_TEXT)
  21.     _files[handle] |= O_TEXT;
  22.   else
  23.     {
  24.       errno = EINVAL;
  25.       return (-1);
  26.     }
  27.   return (old_mode);
  28. }
  29.