2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch#ifndef OSTREAM_FILE_PRIVATE_H
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch#define OSTREAM_FILE_PRIVATE_H
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch#include "ostream-private.h"
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Boschstruct file_ostream {
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch struct ostream_private ostream;
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch ssize_t (*writev)(struct file_ostream *fstream,
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch const struct const_iovec *iov,
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch unsigned int iov_count);
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch int fd;
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch struct io *io;
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch uoff_t buffer_offset;
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch uoff_t real_offset;
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch unsigned char *buffer; /* ring-buffer */
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch size_t buffer_size, optimal_block_size;
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch size_t head, tail; /* first unsent/unused byte */
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool full:1; /* if head == tail, is buffer empty or full? */
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool file:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool flush_pending:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool socket_cork_set:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool no_socket_cork:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool no_sendfile:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool autoclose_fd:1;
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch};
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Boschstruct ostream *
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Boscho_stream_create_file_common(struct file_ostream *fstream,
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch int fd, size_t max_buffer_size, bool autoclose_fd);
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Boschssize_t o_stream_file_writev(struct file_ostream *fstream,
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch const struct const_iovec *iov,
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch unsigned int iov_size);
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Boschssize_t o_stream_file_sendv(struct ostream_private *stream,
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch const struct const_iovec *iov,
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch unsigned int iov_count);
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Boschvoid o_stream_file_close(struct iostream_private *stream,
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch bool close_parent);
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch
2ac0ee86377636dcf9e8c0ddad93842b1fb3d46aStephan Bosch#endif