home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / dos / io / _close.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-25  |  567 b   |  34 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <unistd.h>
  3. #include <errno.h>
  4. #include <go32.h>
  5. #include <dpmi.h>
  6. #include <io.h>
  7. #include <sys/fsext.h>
  8.  
  9. #include <libc/dosio.h>
  10.  
  11. int
  12. _close(int handle)
  13. {
  14.   __dpmi_regs r;
  15.  
  16.   __FSEXT_Function *func = __FSEXT_get_function(handle);
  17.   if (func)
  18.   {
  19.     int rv;
  20.     if (func(__FSEXT_close, &rv, &handle))
  21.       return rv;
  22.   }
  23.  
  24.   r.h.ah = 0x3e;
  25.   r.x.bx = handle;
  26.   __dpmi_int(0x21, &r);
  27.   if (r.x.flags & 1)
  28.   {
  29.     errno = EBADF;
  30.     return -1;
  31.   }
  32.   return 0;
  33. }
  34.