home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_01 / 2n01061a < prev    next >
Text File  |  1990-09-16  |  1KB  |  34 lines

  1. #include<io.h>
  2. #include<errno.h>
  3. #include<dos.h>
  4. #include"redirector.h"
  5.  
  6. /*******************************************************************
  7. *      lock_write() - write shared data to a network file
  8. *
  9. *      Parameters:
  10. *             handle (in) - file handle to read from
  11. *             buffer (in) - buffer to place data in
  12. *             length (in) - number of bytes to read
  13. *
  14. *      Returns:
  15. *             Return code is identical to write()
  16. *
  17. *      Notes:
  18. *             1.     This routine assumes that the record to be written
  19. *                    was previously read using lock_read().
  20. *
  21. *      History:
  22. *             Original code by William H. Roetzheim, 1989
  23. **********************************************************************/
  24.  
  25. int lock_write(int fh, char *buffer, unsigned int length)
  26. {
  27.        int           count;
  28.  
  29.        count = write(fh, buffer, length); /* write data out */
  30.        unlock(fh, lseek(fh, -length, SEEK_CUR), length);
  31.  
  32.        return count;
  33. }
  34.