home *** CD-ROM | disk | FTP | other *** search
- /*-----------------------------------------------------------------------*
- * filename - doswrite.cas
- *
- * function(s)
- * _dos_write - writes data to file (MSC compatible)
- *-----------------------------------------------------------------------*/
-
- /*
- * C/C++ Run Time Library - Version 5.0
- *
- * Copyright (c) 1991, 1992 by Borland International
- * All Rights Reserved.
- *
- */
-
-
- #pragma inline
- #include <asmrules.h>
- #include <io.h>
- #include <_io.h>
-
- /*-----------------------------------------------------------------------*
-
- Name _dos_write - writes data to file
-
- Usage unsigned _dos_write(int handle, void far *buf, unsigned nbyte,
- unsigned *nwrite);
-
- Prototype in dos.h
-
- Description _dos_write is a direct call to the MS-DOS write system call.
- The buffer pointer buf must be a far pointer. The number
- of bytes requested is nbyte.
-
- If the write is successful, the number of bytes actually
- written is stored at *nwrite, which may be less than
- the number of bytes requested.
- No text file translation is performed on the data.
-
- Return value success : 0, and *nwrite is set to no. of bytes written
- else : the DOS error code, and errno is set to
- one of the following:
-
- EACCESS Permission denied
- EBADF Bad file number
-
- Note Compatible with Microsoft C. Not the same as _write().
-
- *------------------------------------------------------------------------*/
- unsigned _dos_write( int fd, void far *buf, unsigned len, unsigned *nwrite )
- {
- asm push ds
- asm mov ah,40h
- asm mov bx,fd
- asm mov cx,len
- asm lds dx, buf
- asm int 21h
- asm pop ds
- asm jc _dos_writeFailed
-
- asm LES_ bx, nwrite
- asm mov ES_ [bx], ax
- return (0);
-
- _dos_writeFailed:
- return (__DOSerror(_AX));
- }
-