buf.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /** @file buf.h
  2. * @brief Public interface for dynamic buffer class.
  3. */
  4. #ifndef _faux_buf_h
  5. #define _faux_buf_h
  6. #include <faux/faux.h>
  7. #include <faux/sched.h>
  8. #define FAUX_BUF_UNLIMITED 0
  9. typedef struct faux_buf_s faux_buf_t;
  10. C_DECL_BEGIN
  11. faux_buf_t *faux_buf_new(size_t chunk_size);
  12. void faux_buf_free(faux_buf_t *buf);
  13. ssize_t faux_buf_len(const faux_buf_t *buf);
  14. ssize_t faux_buf_limit(const faux_buf_t *buf);
  15. bool_t faux_buf_set_limit(faux_buf_t *buf, size_t limit);
  16. size_t faux_buf_is_wlocked(const faux_buf_t *buf);
  17. size_t faux_buf_is_rlocked(const faux_buf_t *buf);
  18. ssize_t faux_buf_write(faux_buf_t *buf, const void *data, size_t len);
  19. ssize_t faux_buf_read(faux_buf_t *buf, void *data, size_t len);
  20. ssize_t faux_buf_dread_lock(faux_buf_t *buf, size_t len,
  21. struct iovec **iov, size_t *iov_num);
  22. ssize_t faux_buf_dread_unlock(faux_buf_t *buf, size_t really_readed,
  23. struct iovec *iov);
  24. ssize_t faux_buf_dwrite_lock(faux_buf_t *buf, size_t len,
  25. struct iovec **iov_out, size_t *iov_num_out);
  26. ssize_t faux_buf_dwrite_unlock(faux_buf_t *buf, size_t really_written,
  27. struct iovec *iov);
  28. C_DECL_END
  29. #endif // _faux_buf_h