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

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