]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // detail/descriptor_ops.hpp | |
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
4 | // | |
1e59de90 | 5 | // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
7c673cae FG |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 | // | |
10 | ||
11 | #ifndef BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP | |
12 | #define BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP | |
13 | ||
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/asio/detail/config.hpp> | |
19 | ||
20 | #if !defined(BOOST_ASIO_WINDOWS) \ | |
21 | && !defined(BOOST_ASIO_WINDOWS_RUNTIME) \ | |
22 | && !defined(__CYGWIN__) | |
23 | ||
24 | #include <cstddef> | |
b32b8144 | 25 | #include <boost/asio/error.hpp> |
7c673cae | 26 | #include <boost/system/error_code.hpp> |
1e59de90 | 27 | #include <boost/asio/detail/cstdint.hpp> |
7c673cae FG |
28 | #include <boost/asio/detail/socket_types.hpp> |
29 | ||
30 | #include <boost/asio/detail/push_options.hpp> | |
31 | ||
32 | namespace boost { | |
33 | namespace asio { | |
34 | namespace detail { | |
35 | namespace descriptor_ops { | |
36 | ||
37 | // Descriptor state bits. | |
38 | enum | |
39 | { | |
40 | // The user wants a non-blocking descriptor. | |
41 | user_set_non_blocking = 1, | |
42 | ||
43 | // The descriptor has been set non-blocking. | |
44 | internal_non_blocking = 2, | |
45 | ||
46 | // Helper "state" used to determine whether the descriptor is non-blocking. | |
47 | non_blocking = user_set_non_blocking | internal_non_blocking, | |
48 | ||
49 | // The descriptor may have been dup()-ed. | |
50 | possible_dup = 4 | |
51 | }; | |
52 | ||
53 | typedef unsigned char state_type; | |
54 | ||
20effc67 TL |
55 | inline void get_last_error( |
56 | boost::system::error_code& ec, bool is_error_condition) | |
7c673cae | 57 | { |
20effc67 TL |
58 | if (!is_error_condition) |
59 | { | |
60 | ec.assign(0, ec.category()); | |
61 | } | |
62 | else | |
63 | { | |
64 | ec = boost::system::error_code(errno, | |
65 | boost::asio::error::get_system_category()); | |
66 | } | |
7c673cae FG |
67 | } |
68 | ||
69 | BOOST_ASIO_DECL int open(const char* path, int flags, | |
70 | boost::system::error_code& ec); | |
71 | ||
1e59de90 TL |
72 | BOOST_ASIO_DECL int open(const char* path, int flags, unsigned mode, |
73 | boost::system::error_code& ec); | |
74 | ||
7c673cae FG |
75 | BOOST_ASIO_DECL int close(int d, state_type& state, |
76 | boost::system::error_code& ec); | |
77 | ||
78 | BOOST_ASIO_DECL bool set_user_non_blocking(int d, | |
79 | state_type& state, bool value, boost::system::error_code& ec); | |
80 | ||
81 | BOOST_ASIO_DECL bool set_internal_non_blocking(int d, | |
82 | state_type& state, bool value, boost::system::error_code& ec); | |
83 | ||
84 | typedef iovec buf; | |
85 | ||
86 | BOOST_ASIO_DECL std::size_t sync_read(int d, state_type state, buf* bufs, | |
87 | std::size_t count, bool all_empty, boost::system::error_code& ec); | |
88 | ||
20effc67 TL |
89 | BOOST_ASIO_DECL std::size_t sync_read1(int d, state_type state, void* data, |
90 | std::size_t size, boost::system::error_code& ec); | |
91 | ||
7c673cae FG |
92 | BOOST_ASIO_DECL bool non_blocking_read(int d, buf* bufs, std::size_t count, |
93 | boost::system::error_code& ec, std::size_t& bytes_transferred); | |
94 | ||
20effc67 TL |
95 | BOOST_ASIO_DECL bool non_blocking_read1(int d, void* data, std::size_t size, |
96 | boost::system::error_code& ec, std::size_t& bytes_transferred); | |
97 | ||
7c673cae FG |
98 | BOOST_ASIO_DECL std::size_t sync_write(int d, state_type state, |
99 | const buf* bufs, std::size_t count, bool all_empty, | |
100 | boost::system::error_code& ec); | |
101 | ||
20effc67 TL |
102 | BOOST_ASIO_DECL std::size_t sync_write1(int d, state_type state, |
103 | const void* data, std::size_t size, boost::system::error_code& ec); | |
104 | ||
7c673cae FG |
105 | BOOST_ASIO_DECL bool non_blocking_write(int d, |
106 | const buf* bufs, std::size_t count, | |
107 | boost::system::error_code& ec, std::size_t& bytes_transferred); | |
20effc67 TL |
108 | |
109 | BOOST_ASIO_DECL bool non_blocking_write1(int d, | |
110 | const void* data, std::size_t size, | |
111 | boost::system::error_code& ec, std::size_t& bytes_transferred); | |
7c673cae | 112 | |
1e59de90 TL |
113 | #if defined(BOOST_ASIO_HAS_FILE) |
114 | ||
115 | BOOST_ASIO_DECL std::size_t sync_read_at(int d, state_type state, | |
116 | uint64_t offset, buf* bufs, std::size_t count, bool all_empty, | |
117 | boost::system::error_code& ec); | |
118 | ||
119 | BOOST_ASIO_DECL std::size_t sync_read_at1(int d, state_type state, | |
120 | uint64_t offset, void* data, std::size_t size, | |
121 | boost::system::error_code& ec); | |
122 | ||
123 | BOOST_ASIO_DECL bool non_blocking_read_at(int d, uint64_t offset, | |
124 | buf* bufs, std::size_t count, boost::system::error_code& ec, | |
125 | std::size_t& bytes_transferred); | |
126 | ||
127 | BOOST_ASIO_DECL bool non_blocking_read_at1(int d, uint64_t offset, | |
128 | void* data, std::size_t size, boost::system::error_code& ec, | |
129 | std::size_t& bytes_transferred); | |
130 | ||
131 | BOOST_ASIO_DECL std::size_t sync_write_at(int d, state_type state, | |
132 | uint64_t offset, const buf* bufs, std::size_t count, bool all_empty, | |
133 | boost::system::error_code& ec); | |
134 | ||
135 | BOOST_ASIO_DECL std::size_t sync_write_at1(int d, state_type state, | |
136 | uint64_t offset, const void* data, std::size_t size, | |
137 | boost::system::error_code& ec); | |
138 | ||
139 | BOOST_ASIO_DECL bool non_blocking_write_at(int d, | |
140 | uint64_t offset, const buf* bufs, std::size_t count, | |
141 | boost::system::error_code& ec, std::size_t& bytes_transferred); | |
142 | ||
143 | BOOST_ASIO_DECL bool non_blocking_write_at1(int d, | |
144 | uint64_t offset, const void* data, std::size_t size, | |
145 | boost::system::error_code& ec, std::size_t& bytes_transferred); | |
146 | ||
147 | #endif // defined(BOOST_ASIO_HAS_FILE) | |
148 | ||
7c673cae FG |
149 | BOOST_ASIO_DECL int ioctl(int d, state_type& state, long cmd, |
150 | ioctl_arg_type* arg, boost::system::error_code& ec); | |
151 | ||
152 | BOOST_ASIO_DECL int fcntl(int d, int cmd, boost::system::error_code& ec); | |
153 | ||
154 | BOOST_ASIO_DECL int fcntl(int d, int cmd, | |
155 | long arg, boost::system::error_code& ec); | |
156 | ||
157 | BOOST_ASIO_DECL int poll_read(int d, | |
158 | state_type state, boost::system::error_code& ec); | |
159 | ||
160 | BOOST_ASIO_DECL int poll_write(int d, | |
161 | state_type state, boost::system::error_code& ec); | |
162 | ||
b32b8144 FG |
163 | BOOST_ASIO_DECL int poll_error(int d, |
164 | state_type state, boost::system::error_code& ec); | |
165 | ||
7c673cae FG |
166 | } // namespace descriptor_ops |
167 | } // namespace detail | |
168 | } // namespace asio | |
169 | } // namespace boost | |
170 | ||
171 | #include <boost/asio/detail/pop_options.hpp> | |
172 | ||
173 | #if defined(BOOST_ASIO_HEADER_ONLY) | |
174 | # include <boost/asio/detail/impl/descriptor_ops.ipp> | |
175 | #endif // defined(BOOST_ASIO_HEADER_ONLY) | |
176 | ||
177 | #endif // !defined(BOOST_ASIO_WINDOWS) | |
178 | // && !defined(BOOST_ASIO_WINDOWS_RUNTIME) | |
179 | // && !defined(__CYGWIN__) | |
180 | ||
181 | #endif // BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP |