You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

25 lines
771 B

  1. #pragma once
  2. #include <stddef.h>
  3. enum async_write_status {ASYNC_WRITE_DONE, ASYNC_WRITE_REMAIN, ASYNC_WRITE_ERR};
  4. /*
  5. * Primitive that writes data to a NONBLOCK:ing FD.
  6. *
  7. * _data: points to the beginning of the buffer
  8. * len: total size of the data buffer
  9. * idx: pointer to byte offset into data buffer - writing starts here.
  10. *
  11. * Thus, the total amount of data to write is (len - *idx). *idx is
  12. * updated such that it points to the next unwritten byte in the data
  13. * buffer.
  14. *
  15. * I.e. if the return value is:
  16. * - ASYNC_WRITE_DONE, then the *idx == len.
  17. * - ASYNC_WRITE_REMAIN, then *idx < len
  18. * - ASYNC_WRITE_ERR, there was an error, and no data was written
  19. */
  20. enum async_write_status async_write(
  21. int fd, const void *data, size_t len, size_t *idx);