home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / DOSREAD.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  2.0 KB  |  68 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - dosread.cas
  3.  *
  4.  * function(s)
  5.  *        _dos_read - reads from file (MSC compatible)
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1991, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma inline
  18. #include <asmrules.h>
  19. #include <io.h>
  20. #include <_io.h>
  21.  
  22. /*-----------------------------------------------------------------------*
  23.  
  24. Name            _dos_read - reads from file
  25.  
  26. Usage           unsigned _dos_read(int handle, void far *buf, unsigned nbyte,
  27.                                 unsigned *nread);
  28.  
  29. Prototype in    dos.h
  30.  
  31. Description     _dos_read is a direct call to the MS-DOS read system call.
  32.                 The buffer pointer buf must be a far pointer.  The number
  33.                 of bytes requested is nbyte.
  34.  
  35.                 If the read is successful, the number of bytes actually
  36.                 read is stored at *nread.  If *nread is 0, an attempt
  37.                 was made to read at the end of file.
  38.                 No text file translation is performed on the data read.
  39.  
  40. Return value    success : 0, and *nread is set to no. of bytes read
  41.                 else    : the DOS error code, and errno is set to
  42.                           one of the following:
  43.  
  44.                         EACCESS  Permission denied
  45.                         EBADF    Bad file number
  46.  
  47. Note            Compatible with Microsoft C.  Not the same as _read().
  48.  
  49. *------------------------------------------------------------------------*/
  50. unsigned  _dos_read( int fd, void far *buf, unsigned len, unsigned *nread )
  51. {
  52. asm     push    ds
  53. asm     mov     ah,3fh
  54. asm     mov     bx,fd
  55. asm     mov     cx,len
  56. asm     lds     dx, buf
  57. asm     int     21h
  58. asm     pop     ds
  59. asm     jc      _dos_readFailed
  60.  
  61. asm     LES_    bx, nread
  62. asm     mov     ES_ [bx], ax
  63.         return  (0);
  64.  
  65. _dos_readFailed:
  66.         return (__DOSerror(_AX));
  67. }
  68.