1 | // |
2 | // detail/descriptor_ops.hpp |
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 | // |
5 | // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
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> |
25 | #include <boost/system/error_code.hpp> |
26 | #include <boost/asio/detail/socket_types.hpp> |
27 | |
28 | #include <boost/asio/detail/push_options.hpp> |
29 | |
30 | namespace boost { |
31 | namespace asio { |
32 | namespace detail { |
33 | namespace descriptor_ops { |
34 | |
35 | // Descriptor state bits. |
36 | enum |
37 | { |
38 | // The user wants a non-blocking descriptor. |
39 | user_set_non_blocking = 1, |
40 | |
41 | // The descriptor has been set non-blocking. |
42 | internal_non_blocking = 2, |
43 | |
44 | // Helper "state" used to determine whether the descriptor is non-blocking. |
45 | non_blocking = user_set_non_blocking | internal_non_blocking, |
46 | |
47 | // The descriptor may have been dup()-ed. |
48 | possible_dup = 4 |
49 | }; |
50 | |
51 | typedef unsigned char state_type; |
52 | |
53 | template <typename ReturnType> |
54 | inline ReturnType error_wrapper(ReturnType return_value, |
55 | boost::system::error_code& ec) |
56 | { |
57 | ec = boost::system::error_code(errno, |
58 | boost::asio::error::get_system_category()); |
59 | return return_value; |
60 | } |
61 | |
62 | BOOST_ASIO_DECL int open(const char* path, int flags, |
63 | boost::system::error_code& ec); |
64 | |
65 | BOOST_ASIO_DECL int close(int d, state_type& state, |
66 | boost::system::error_code& ec); |
67 | |
68 | BOOST_ASIO_DECL bool set_user_non_blocking(int d, |
69 | state_type& state, bool value, boost::system::error_code& ec); |
70 | |
71 | BOOST_ASIO_DECL bool set_internal_non_blocking(int d, |
72 | state_type& state, bool value, boost::system::error_code& ec); |
73 | |
74 | typedef iovec buf; |
75 | |
76 | BOOST_ASIO_DECL std::size_t sync_read(int d, state_type state, buf* bufs, |
77 | std::size_t count, bool all_empty, boost::system::error_code& ec); |
78 | |
79 | BOOST_ASIO_DECL bool non_blocking_read(int d, buf* bufs, std::size_t count, |
80 | boost::system::error_code& ec, std::size_t& bytes_transferred); |
81 | |
82 | BOOST_ASIO_DECL std::size_t sync_write(int d, state_type state, |
83 | const buf* bufs, std::size_t count, bool all_empty, |
84 | boost::system::error_code& ec); |
85 | |
86 | BOOST_ASIO_DECL bool non_blocking_write(int d, |
87 | const buf* bufs, std::size_t count, |
88 | boost::system::error_code& ec, std::size_t& bytes_transferred); |
89 | |
90 | BOOST_ASIO_DECL int ioctl(int d, state_type& state, long cmd, |
91 | ioctl_arg_type* arg, boost::system::error_code& ec); |
92 | |
93 | BOOST_ASIO_DECL int fcntl(int d, int cmd, boost::system::error_code& ec); |
94 | |
95 | BOOST_ASIO_DECL int fcntl(int d, int cmd, |
96 | long arg, boost::system::error_code& ec); |
97 | |
98 | BOOST_ASIO_DECL int poll_read(int d, |
99 | state_type state, boost::system::error_code& ec); |
100 | |
101 | BOOST_ASIO_DECL int poll_write(int d, |
102 | state_type state, boost::system::error_code& ec); |
103 | |
104 | } // namespace descriptor_ops |
105 | } // namespace detail |
106 | } // namespace asio |
107 | } // namespace boost |
108 | |
109 | #include <boost/asio/detail/pop_options.hpp> |
110 | |
111 | #if defined(BOOST_ASIO_HEADER_ONLY) |
112 | # include <boost/asio/detail/impl/descriptor_ops.ipp> |
113 | #endif // defined(BOOST_ASIO_HEADER_ONLY) |
114 | |
115 | #endif // !defined(BOOST_ASIO_WINDOWS) |
116 | // && !defined(BOOST_ASIO_WINDOWS_RUNTIME) |
117 | // && !defined(__CYGWIN__) |
118 | |
119 | #endif // BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP |
120 | |