home *** CD-ROM | disk | FTP | other *** search
- /*-----------------------------------------------------------------------*
- * filename - reada.cas
- *
- * function(s)
- * _read - reads from file
- *-----------------------------------------------------------------------*/
-
- /*[]------------------------------------------------------------[]*/
- /*| |*/
- /*| Turbo C Run Time Library - Version 3.0 |*/
- /*| |*/
- /*| |*/
- /*| Copyright (c) 1987,1988,1990 by Borland International |*/
- /*| All Rights Reserved. |*/
- /*| |*/
- /*[]------------------------------------------------------------[]*/
-
- #pragma inline
- #include <asmrules.h>
- #include <io.h>
- #include <_io.h>
-
- /*-----------------------------------------------------------------------*
-
- Name _read - reads from file
-
- Usage int _read(int handle, void *buf, unsigned nbyte);
-
- Prototype in io.h
-
- Description _read is a direct call to the MS-DOS read system call.
- see read in READ.CAS
-
- Return value Upon successful completion, a positive integer is
- returned indicating the number of bytes placed in the buffer;
- if the file was opened in text mode, read does not count
- carriage returns or <Ctrl-Z> characters in the number of
- bytes read.
-
- On end-of-file, both functions return zero. On error, both
- functions return -1 and errno is set to one of the following:
-
- EACCES Permission denied
- EBADF Bad file number
-
- *------------------------------------------------------------------------*/
- int _CType _read( int fd, void *buf, unsigned len )
- {
- pushDS_
- asm mov ah,3fh
- asm mov bx,fd
- asm mov cx,len
- asm LDS_ dx, buf
- asm int 21h
- popDS_
- asm jc _readFailed
- return(_AX);
-
- _readFailed:
- return __IOerror (_AX);
- }
-