William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 1 | #include <fcntl.h> |
Patrick Williams | d1984dd | 2023-05-10 16:12:44 -0500 | [diff] [blame] | 2 | #include <sys/socket.h> |
| 3 | |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 4 | #include <stdplus/fd/create.hpp> |
| 5 | #include <stdplus/util/cexec.hpp> |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 6 | |
William A. Kennington III | 6417c63 | 2023-07-17 02:56:52 -0700 | [diff] [blame] | 7 | #include <format> |
| 8 | |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 9 | namespace stdplus |
| 10 | { |
| 11 | namespace fd |
| 12 | { |
| 13 | |
William A. Kennington III | e6fda45 | 2023-07-26 15:12:12 -0700 | [diff] [blame] | 14 | DupableFd open(const_zstring pathname, OpenFlags flags, mode_t mode) |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 15 | { |
| 16 | return DupableFd( |
William A. Kennington III | e6fda45 | 2023-07-26 15:12:12 -0700 | [diff] [blame] | 17 | CHECK_ERRNO(::open(pathname.c_str(), static_cast<int>(flags), mode), |
| 18 | std::format("open `{}`", pathname.c_str()))); |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | DupableFd socket(SocketDomain domain, SocketType type, SocketProto protocol) |
| 22 | { |
| 23 | return DupableFd( |
| 24 | CHECK_ERRNO(::socket(static_cast<int>(domain), static_cast<int>(type), |
| 25 | static_cast<int>(protocol)), |
| 26 | "socket")); |
| 27 | } |
| 28 | |
| 29 | } // namespace fd |
| 30 | } // namespace stdplus |