12#ifndef OPENVPN_COMMON_PIPE_H
13#define OPENVPN_COMMON_PIPE_H
34 sd.reset(
new openvpn_io::posix::stream_descriptor(io_context, fd.
release()));
43 std::unique_ptr<openvpn_io::posix::stream_descriptor>
sd;
49 SD_OUT(openvpn_io::io_context &io_context,
const std::string &content,
ScopedFD &fd)
63 [
this](
const openvpn_io::error_code &ec,
const size_t bytes_sent)
65 if (!ec && bytes_sent < buf.size())
67 buf.advance(bytes_sent);
92 return data.to_string();
98 buf.reset(0, 2048, BufAllocFlags::NO_FLAGS);
99 sd->async_read_some(buf.mutable_buffer_clamp(),
100 [
this](
const openvpn_io::error_code &ec,
const size_t bytes_recvd)
104 buf.set_size(bytes_recvd);
105 data.put_consume(buf);
123 const int eno = errno;
openvpn_io::const_buffer const_buffer_limit(const size_t limit) const
Return a const_buffer object with a specified size limit.
const std::string content() const
SD_IN(openvpn_io::io_context &io_context, ScopedFD &fd)
SD_OUT(openvpn_io::io_context &io_context, const std::string &content, ScopedFD &fd)
std::unique_ptr< openvpn_io::posix::stream_descriptor > sd
SD(openvpn_io::io_context &io_context, ScopedFD &fd)
void reset(const int fd_arg)
#define OPENVPN_THROW_EXCEPTION(stuff)
void make_pipe(int fd[2])
BufferAllocated buf_alloc_from_string(const std::string &str)
std::string strerror_str(const int errnum)