home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / dos / compat / d_write.txh < prev    next >
Encoding:
Text File  |  1995-10-09  |  1.3 KB  |  50 lines

  1. @node _dos_write, dos
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <dos.h>
  6.  
  7. unsigned int _dos_write(int handle, const void *buffer, unsigned int count,
  8.                         unsigned int *result);
  9. @end example
  10.  
  11. @subheading Description
  12.  
  13. This is a direct connection to the MS-DOS write function call (%ah = 0x40).
  14. No conversion is done on the data; it is written as raw binary data. This
  15. function writes @var{count} bytes from @var{buffer} to @var{handle}.
  16. @var{count} value may be arbitrary size (e.g. > 64KB). It puts number of
  17. bytes written into @var{result} if writing is successful.
  18.  
  19. @xref{_dos_open}. @xref{_dos_creat}. @xref{_dos_creatnew}.
  20. @xref{_dos_read}. @xref{_dos_close}
  21.  
  22. @subheading Return Value
  23.  
  24. Returns 0 if successful or DOS error code on error (and sets @var{errno}
  25. to EACCES or EBADF)
  26.  
  27. @subheading Example
  28.  
  29. @example
  30. int handle;
  31. unsigned int result;
  32. char *filebuffer;
  33.  
  34. if ( !_dos_creat("FOO.DAT", _A_ARCH, &handle) )
  35. @{
  36.    puts("FOO.DAT creating was successful.");
  37.    if ( (filebuffer = malloc(130000)) != NULL )
  38.    @{
  39.      ...
  40.      /* Put something into filebuffer. */
  41.      ...
  42.      if ( !_dos_write(handle, buffer, 130000, &result) )
  43.        printf("%u bytes written into FOO.DAT.", result);
  44.      else
  45.        puts("Writing error.");
  46.    @}
  47.    _dos_close(handle);
  48. @}
  49. @end example
  50.