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

  1. /**
  2. *
  3. * Name        flread -- Read from a file to a buffer
  4. *
  5. * Synopsis    ercode = flread(handle,pbufads,nbytes,pnread);
  6. *
  7. *        int  ercode      DOS function return error code
  8. *        int  handle      File handle
  9. *        ADS  *pbufads      Segment, offset address of input buffer
  10. *        unsigned nbytes   Number of bytes to read
  11. *        unsigned *pnread  Number of bytes actually returned
  12. *
  13. * Description    FLREAD transfers the specified number of bytes (nbytes)
  14. *        from the file (whose handle is specified) to a buffer
  15. *        whose segment and offset address is pointed to by
  16. *        pbufads.  The number of bytes actually read is also
  17. *        returned.  The file pointer is moved the number of bytes
  18. *        read; therefore, successive calls to FLREAD sequentially
  19. *        read the file.
  20. *
  21. * Returns    ercode          DOS function error code
  22. *        *pnread       The number of bytes transferred to the
  23. *                  I/O buffer.
  24. *
  25. * Version      3.0  (C)Copyright Blaise Computing Inc.    1983, 1984, 1986
  26. *
  27. **/
  28.  
  29. #include <bfile.h>
  30.  
  31. int flread(handle,pbufads,nbytes,pnread)
  32. int handle;
  33. ADS *pbufads;
  34. unsigned nbytes,*pnread;
  35. {
  36.     DOSREG dos_reg;
  37.     int    ercode;
  38.  
  39.     dos_reg.ax = 0x3f00;          /* DOS function 0x3F          */
  40.     dos_reg.bx = handle;
  41.     dos_reg.cx = nbytes;
  42.     dos_reg.dx = pbufads->r;
  43.     dos_reg.ds = pbufads->s;
  44.     ercode     = dos(&dos_reg);
  45.     *pnread    = dos_reg.ax;
  46.  
  47.     return(ercode);
  48. }
  49.