home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / FLSEEK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.8 KB  |  58 lines

  1. /**
  2. *
  3. * Name        flseek -- Position the file pointer
  4. *
  5. * Synopsis    ercode = flseek(handle,mov,ppos);
  6. *
  7. *        int  ercode      DOS error return code
  8. *        int  handle      Handle of file to be positioned
  9. *        int  mov      Positioning technique
  10. *        long *ppos      File position
  11. *
  12. * Description    Each handle of an open file has a file position pointer
  13. *        associated with it.  FLSEEK moves the pointer using the
  14. *        technique specified in mov.  The possibilities are:
  15. *
  16. *            ABSOLUTE (0) - Move the pointer to the offset specified
  17. *            in *ppos from the beginning of the file.
  18. *            RELATIVE (1) - Move the pointer to the specified offset
  19. *            relative to the current file position.
  20. *            ENDFILE  (2) - Move the pointer to the offset from
  21. *            the end of the file.
  22. *
  23. *        Upon input, *ppos contains the offset in bytes to move
  24. *        the file pointer, and upon return, the new file pointer
  25. *        location.  The functions FLREAD and FLWRITE also alter
  26. *        the file pointer position.
  27. *
  28. * Returns    ercode          DOS 2.0 function error return code
  29. *        *ppos          The file pointer position after the seek
  30. *                  has been accomplished.  If an error is
  31. *                  encountered, the position is set to -1.
  32. *
  33. * Version    3.0  (C)Copyright Blaise Computing Inc.  1983, 1984, 1986
  34. *
  35. **/
  36.  
  37. #include <bfile.h>
  38.  
  39. int flseek(handle,mov,ppos)
  40. int  handle,mov;
  41. long *ppos;
  42. {
  43.     DOSREG dos_reg;
  44.     int    ercode;
  45.  
  46.     dos_reg.ax = utbyword(0x42,mov);  /* Function call 0x42          */
  47.     dos_reg.bx = handle;
  48.     dos_reg.cx = (unsigned) uthiword(*ppos);     /* High order and    */
  49.     dos_reg.dx = (unsigned) utloword(*ppos);     /* low order words   */
  50.     ercode     = dos(&dos_reg);
  51.     if (ercode == 0)
  52.        *ppos = (((long)(dos_reg.dx)) << 16) + (long)dos_reg.ax;
  53.     else
  54.        *ppos = -1L;
  55.  
  56.     return(ercode);
  57. }
  58.