home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / READA.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.1 KB  |  62 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - reada.cas
  3.  *
  4.  * function(s)
  5.  *        _read - reads from file
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #pragma inline
  19. #include <asmrules.h>
  20. #include <io.h>
  21. #include <_io.h>
  22.  
  23. /*-----------------------------------------------------------------------*
  24.  
  25. Name            _read - reads from file
  26.  
  27. Usage           int _read(int handle, void *buf, unsigned nbyte);
  28.  
  29. Prototype in    io.h
  30.  
  31. Description     _read is a direct call to the MS-DOS read system call.
  32.                 see read in READ.CAS
  33.  
  34. Return value    Upon successful completion, a positive integer is
  35.                 returned indicating the number of bytes placed in the buffer;
  36.                 if the file was opened in text mode, read does not count
  37.                 carriage returns or <Ctrl-Z> characters in the number of
  38.                 bytes read.
  39.  
  40.                 On end-of-file, both functions return zero. On error, both
  41.                 functions return -1 and errno is set to one of the following:
  42.  
  43.                         EACCES  Permission denied
  44.                         EBADF   Bad file number
  45.  
  46. *------------------------------------------------------------------------*/
  47. int _CType _read( int fd, void *buf, unsigned len )
  48. {
  49.     pushDS_
  50. asm    mov    ah,3fh
  51. asm    mov    bx,fd
  52. asm    mov    cx,len
  53. asm    LDS_    dx, buf
  54. asm    int    21h
  55.     popDS_
  56. asm    jc    _readFailed
  57.     return(_AX);
  58.  
  59. _readFailed:
  60.     return __IOerror (_AX);
  61. }
  62.