1 | // Take a look at the license at the top of the repository in the LICENSE file. |
2 | |
3 | #[cfg (not(target_family = "windows" ))] |
4 | pub use self::libc_constants::*; |
5 | #[cfg (target_family = "windows" )] |
6 | pub use self::windows_constants::*; |
7 | |
8 | pub type GSocketFamily = libc::c_int; |
9 | pub type GSocketMsgFlags = libc::c_int; |
10 | |
11 | #[cfg (target_family = "windows" )] |
12 | mod windows_constants { |
13 | pub const G_SOCKET_FAMILY_INVALID: super::GSocketFamily = winapi::shared::ws2def::AF_UNSPEC; |
14 | pub const G_SOCKET_FAMILY_UNIX: super::GSocketFamily = winapi::shared::ws2def::AF_UNIX; |
15 | pub const G_SOCKET_FAMILY_IPV4: super::GSocketFamily = winapi::shared::ws2def::AF_INET; |
16 | pub const G_SOCKET_FAMILY_IPV6: super::GSocketFamily = winapi::shared::ws2def::AF_INET6; |
17 | |
18 | pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0; |
19 | pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = winapi::um::winsock2::MSG_OOB; |
20 | pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = winapi::um::winsock2::MSG_PEEK; |
21 | pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = winapi::um::winsock2::MSG_DONTROUTE; |
22 | } |
23 | |
24 | #[cfg (not(target_family = "windows" ))] |
25 | mod libc_constants { |
26 | pub const G_SOCKET_FAMILY_INVALID: super::GSocketFamily = libc::AF_UNSPEC; |
27 | pub const G_SOCKET_FAMILY_UNIX: super::GSocketFamily = libc::AF_UNIX; |
28 | pub const G_SOCKET_FAMILY_IPV4: super::GSocketFamily = libc::AF_INET; |
29 | pub const G_SOCKET_FAMILY_IPV6: super::GSocketFamily = libc::AF_INET6; |
30 | |
31 | pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0; |
32 | pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = libc::MSG_OOB; |
33 | pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = libc::MSG_PEEK; |
34 | pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = libc::MSG_DONTROUTE; |
35 | } |
36 | |
37 | #[cfg (target_family = "windows" )] |
38 | pub use self::windows_streams::*; |
39 | |
40 | #[cfg (target_family = "windows" )] |
41 | mod windows_streams { |
42 | use libc::c_void; |
43 | |
44 | use crate::{ |
45 | gboolean, GInputStream, GInputStreamClass, GOutputStream, GOutputStreamClass, GType, |
46 | }; |
47 | |
48 | #[link (name = "gio-2.0" )] |
49 | extern "C" { |
50 | //========================================================================= |
51 | // GWin32InputStream |
52 | //========================================================================= |
53 | pub fn g_win32_input_stream_get_type() -> GType; |
54 | pub fn g_win32_input_stream_new( |
55 | handle: *mut c_void, |
56 | close_handle: gboolean, |
57 | ) -> *mut GInputStream; |
58 | pub fn g_win32_input_stream_get_close_handle(stream: *mut GWin32InputStream) -> gboolean; |
59 | pub fn g_win32_input_stream_get_handle(stream: *mut GWin32InputStream) -> *mut c_void; |
60 | pub fn g_win32_input_stream_set_close_handle( |
61 | stream: *mut GWin32InputStream, |
62 | close_handle: gboolean, |
63 | ); |
64 | |
65 | //========================================================================= |
66 | // GWin32OutputStream |
67 | //========================================================================= |
68 | pub fn g_win32_output_stream_get_type() -> GType; |
69 | pub fn g_win32_output_stream_new( |
70 | handle: *mut c_void, |
71 | close_handle: gboolean, |
72 | ) -> *mut GOutputStream; |
73 | pub fn g_win32_output_stream_get_close_handle(stream: *mut GWin32OutputStream) -> gboolean; |
74 | pub fn g_win32_output_stream_get_handle(stream: *mut GWin32OutputStream) -> *mut c_void; |
75 | pub fn g_win32_output_stream_set_close_handle( |
76 | stream: *mut GWin32OutputStream, |
77 | close_handle: gboolean, |
78 | ); |
79 | } |
80 | |
81 | #[repr (C)] |
82 | #[derive (Copy, Clone)] |
83 | pub struct GWin32InputStreamClass { |
84 | pub parent_class: GInputStreamClass, |
85 | pub _g_reserved1: Option<unsafe extern "C" fn()>, |
86 | pub _g_reserved2: Option<unsafe extern "C" fn()>, |
87 | pub _g_reserved3: Option<unsafe extern "C" fn()>, |
88 | pub _g_reserved4: Option<unsafe extern "C" fn()>, |
89 | pub _g_reserved5: Option<unsafe extern "C" fn()>, |
90 | } |
91 | |
92 | impl ::std::fmt::Debug for GWin32InputStreamClass { |
93 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
94 | f.debug_struct(&format!("GWin32InputStreamClass @ {:?}" , self as *const _)) |
95 | .field("parent_class" , &self.parent_class) |
96 | .field("_g_reserved1" , &self._g_reserved1) |
97 | .field("_g_reserved2" , &self._g_reserved2) |
98 | .field("_g_reserved3" , &self._g_reserved3) |
99 | .field("_g_reserved4" , &self._g_reserved4) |
100 | .field("_g_reserved5" , &self._g_reserved5) |
101 | .finish() |
102 | } |
103 | } |
104 | |
105 | #[repr (C)] |
106 | pub struct _GWin32InputStreamPrivate(c_void); |
107 | |
108 | pub type GWin32InputStreamPrivate = *mut _GWin32InputStreamPrivate; |
109 | |
110 | #[repr (C)] |
111 | #[derive (Copy, Clone)] |
112 | pub struct GWin32InputStream { |
113 | pub parent_instance: GInputStream, |
114 | pub priv_: *mut GWin32InputStreamPrivate, |
115 | } |
116 | |
117 | impl ::std::fmt::Debug for GWin32InputStream { |
118 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
119 | f.debug_struct(&format!("GWin32InputStream @ {:?}" , self as *const _)) |
120 | .field("parent_instance" , &self.parent_instance) |
121 | .finish() |
122 | } |
123 | } |
124 | |
125 | #[repr (C)] |
126 | #[derive (Copy, Clone)] |
127 | pub struct GWin32OutputStreamClass { |
128 | pub parent_class: GOutputStreamClass, |
129 | pub _g_reserved1: Option<unsafe extern "C" fn()>, |
130 | pub _g_reserved2: Option<unsafe extern "C" fn()>, |
131 | pub _g_reserved3: Option<unsafe extern "C" fn()>, |
132 | pub _g_reserved4: Option<unsafe extern "C" fn()>, |
133 | pub _g_reserved5: Option<unsafe extern "C" fn()>, |
134 | } |
135 | |
136 | impl ::std::fmt::Debug for GWin32OutputStreamClass { |
137 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
138 | f.debug_struct(&format!("GWin32OutputStreamClass @ {:?}" , self as *const _)) |
139 | .field("parent_class" , &self.parent_class) |
140 | .field("_g_reserved1" , &self._g_reserved1) |
141 | .field("_g_reserved2" , &self._g_reserved2) |
142 | .field("_g_reserved3" , &self._g_reserved3) |
143 | .field("_g_reserved4" , &self._g_reserved4) |
144 | .field("_g_reserved5" , &self._g_reserved5) |
145 | .finish() |
146 | } |
147 | } |
148 | |
149 | #[repr (C)] |
150 | pub struct _GWin32OutputStreamPrivate(c_void); |
151 | |
152 | pub type GWin32OutputStreamPrivate = *mut _GWin32OutputStreamPrivate; |
153 | |
154 | #[repr (C)] |
155 | #[derive (Copy, Clone)] |
156 | pub struct GWin32OutputStream { |
157 | pub parent_instance: GOutputStream, |
158 | pub priv_: *mut GWin32OutputStreamPrivate, |
159 | } |
160 | |
161 | impl ::std::fmt::Debug for GWin32OutputStream { |
162 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
163 | f.debug_struct(&format!("GWin32OutputStream @ {:?}" , self as *const _)) |
164 | .field("parent_instance" , &self.parent_instance) |
165 | .finish() |
166 | } |
167 | } |
168 | } |
169 | |