home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / posix / unistd / lseek.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-26  |  535 b   |  27 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <libc/stubs.h>
  3. #include <unistd.h>
  4. #include <errno.h>
  5. #include <go32.h>
  6. #include <dpmi.h>
  7.  
  8. #include <libc/dosio.h>
  9.  
  10. off_t
  11. lseek(int handle, off_t offset, int whence)
  12. {
  13.   __dpmi_regs r;
  14.   r.h.ah = 0x42;
  15.   r.h.al = whence;
  16.   r.x.bx = handle;
  17.   r.x.cx = offset >> 16;
  18.   r.x.dx = offset & 0xffff;
  19.   __dpmi_int(0x21, &r);
  20.   if (r.x.flags & 1)
  21.   {
  22.     errno = __doserr_to_errno(r.x.ax);
  23.     return -1;
  24.   }
  25.   return (r.x.dx << 16) + r.x.ax;
  26. }
  27.