home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / FLWRITE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.3 KB  |  48 lines

  1. /**
  2. *
  3. * Name        flwrite -- Write to a file from a buffer
  4. *
  5. * Synopsis    ercode = flwrite(handle,pbufads,nbytes,pnwrote);
  6. *
  7. *        int ercode      Returned DOS function code
  8. *        int handle      File handle
  9. *        ADS *pbufads      Segment, offset address of I/O buffer
  10. *        unsigned nbytes   Number of bytes to write
  11. *        unsigned *pnwrote Number of bytes actually written
  12. *
  13. * Description    This function writes nbytes from the buffer whose
  14. *        address is specified in pbufads to the file associated
  15. *        with the given handle.    The number of bytes actually
  16. *        written is returned in *pnwrote.  The file pointer is
  17. *        moved the number of bytes actually written.  The ADS
  18. *        type is used for the buffer to allow I/O buffers outside
  19. *        the default data segment.
  20. *
  21. * Returns    ercode          DOS function error return code
  22. *        *pnwrote      The number of bytes written to the file.
  23. *
  24. * Version    3.0  (C)Copyright Blaise Computing Inc.  1983, 1984, 1986
  25. *
  26. **/
  27.  
  28. #include <bfile.h>
  29.  
  30. int flwrite(handle,pbufads,nbytes,pnwrote)
  31. int handle;
  32. ADS *pbufads;
  33. unsigned nbytes,*pnwrote;
  34. {
  35.     DOSREG dos_reg;
  36.     int    ercode;
  37.  
  38.     dos_reg.ax = 0x4000;          /* DOS function 0x40          */
  39.     dos_reg.bx = handle;
  40.     dos_reg.cx = nbytes;
  41.     dos_reg.dx = pbufads->r;
  42.     dos_reg.ds = pbufads->s;
  43.     ercode     = dos(&dos_reg);
  44.     *pnwrote   = dos_reg.ax;
  45.  
  46.     return(ercode);
  47. }
  48.