better with obs forms
[ghsmtp.git] / POSIX.hpp
blob19e42fe367aee0af5555518a008cd2e07a2006b1
1 #ifndef POSIX_DOT_HPP
2 #define POSIX_DOT_HPP
4 #include <chrono>
5 #include <functional>
6 #include <ios>
8 #include <unistd.h>
10 constexpr void null_hook(void) {}
12 class POSIX {
13 public:
14 POSIX() = delete;
15 POSIX(POSIX const&) = delete;
17 static void set_nonblocking(int fd);
19 static bool input_ready(int fd_in, std::chrono::milliseconds wait);
20 static bool output_ready(int fd_out, std::chrono::milliseconds wait);
22 static std::streamsize read(int fd,
23 char* s,
24 std::streamsize n,
25 std::function<void(void)> read_hook,
26 std::chrono::milliseconds timeout,
27 bool& t_o);
29 static std::streamsize write(int fd,
30 const char* s,
31 std::streamsize n,
32 std::chrono::milliseconds timeout,
33 bool& t_o);
36 #endif // POSIX_DOT_HPP