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 = |
14 | windows_sys::Win32::Networking::WinSock::AF_UNSPEC as super::GSocketFamily; |
15 | pub const G_SOCKET_FAMILY_UNIX: super::GSocketFamily = |
16 | windows_sys::Win32::Networking::WinSock::AF_UNIX as super::GSocketFamily; |
17 | pub const G_SOCKET_FAMILY_IPV4: super::GSocketFamily = |
18 | windows_sys::Win32::Networking::WinSock::AF_INET as super::GSocketFamily; |
19 | pub const G_SOCKET_FAMILY_IPV6: super::GSocketFamily = |
20 | windows_sys::Win32::Networking::WinSock::AF_INET6 as super::GSocketFamily; |
21 | |
22 | pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0; |
23 | pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = |
24 | windows_sys::Win32::Networking::WinSock::MSG_OOB; |
25 | pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = |
26 | windows_sys::Win32::Networking::WinSock::MSG_PEEK; |
27 | pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = |
28 | windows_sys::Win32::Networking::WinSock::MSG_DONTROUTE; |
29 | } |
30 | |
31 | #[cfg (not(target_family = "windows" ))] |
32 | mod libc_constants { |
33 | pub const G_SOCKET_FAMILY_INVALID: super::GSocketFamily = libc::AF_UNSPEC; |
34 | pub const G_SOCKET_FAMILY_UNIX: super::GSocketFamily = libc::AF_UNIX; |
35 | pub const G_SOCKET_FAMILY_IPV4: super::GSocketFamily = libc::AF_INET; |
36 | pub const G_SOCKET_FAMILY_IPV6: super::GSocketFamily = libc::AF_INET6; |
37 | |
38 | pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0; |
39 | pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = libc::MSG_OOB; |
40 | pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = libc::MSG_PEEK; |
41 | pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = libc::MSG_DONTROUTE; |
42 | } |
43 | |
44 | #[cfg (target_family = "windows" )] |
45 | pub use self::windows_streams::*; |
46 | |
47 | #[cfg (target_family = "windows" )] |
48 | mod windows_streams { |
49 | use libc::c_void; |
50 | |
51 | use crate::{ |
52 | gboolean, GInputStream, GInputStreamClass, GOutputStream, GOutputStreamClass, GType, |
53 | }; |
54 | |
55 | extern "C" { |
56 | //========================================================================= |
57 | // GWin32InputStream |
58 | //========================================================================= |
59 | pub fn g_win32_input_stream_get_type() -> GType; |
60 | pub fn g_win32_input_stream_new( |
61 | handle: *mut c_void, |
62 | close_handle: gboolean, |
63 | ) -> *mut GInputStream; |
64 | pub fn g_win32_input_stream_get_close_handle(stream: *mut GWin32InputStream) -> gboolean; |
65 | pub fn g_win32_input_stream_get_handle(stream: *mut GWin32InputStream) -> *mut c_void; |
66 | pub fn g_win32_input_stream_set_close_handle( |
67 | stream: *mut GWin32InputStream, |
68 | close_handle: gboolean, |
69 | ); |
70 | |
71 | //========================================================================= |
72 | // GWin32OutputStream |
73 | //========================================================================= |
74 | pub fn g_win32_output_stream_get_type() -> GType; |
75 | pub fn g_win32_output_stream_new( |
76 | handle: *mut c_void, |
77 | close_handle: gboolean, |
78 | ) -> *mut GOutputStream; |
79 | pub fn g_win32_output_stream_get_close_handle(stream: *mut GWin32OutputStream) -> gboolean; |
80 | pub fn g_win32_output_stream_get_handle(stream: *mut GWin32OutputStream) -> *mut c_void; |
81 | pub fn g_win32_output_stream_set_close_handle( |
82 | stream: *mut GWin32OutputStream, |
83 | close_handle: gboolean, |
84 | ); |
85 | } |
86 | |
87 | #[repr (C)] |
88 | #[derive (Copy, Clone)] |
89 | pub struct GWin32InputStreamClass { |
90 | pub parent_class: GInputStreamClass, |
91 | pub _g_reserved1: Option<unsafe extern "C" fn()>, |
92 | pub _g_reserved2: Option<unsafe extern "C" fn()>, |
93 | pub _g_reserved3: Option<unsafe extern "C" fn()>, |
94 | pub _g_reserved4: Option<unsafe extern "C" fn()>, |
95 | pub _g_reserved5: Option<unsafe extern "C" fn()>, |
96 | } |
97 | |
98 | impl ::std::fmt::Debug for GWin32InputStreamClass { |
99 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
100 | f.debug_struct(&format!("GWin32InputStreamClass @ {:?}" , self as *const _)) |
101 | .field("parent_class" , &self.parent_class) |
102 | .field("_g_reserved1" , &self._g_reserved1) |
103 | .field("_g_reserved2" , &self._g_reserved2) |
104 | .field("_g_reserved3" , &self._g_reserved3) |
105 | .field("_g_reserved4" , &self._g_reserved4) |
106 | .field("_g_reserved5" , &self._g_reserved5) |
107 | .finish() |
108 | } |
109 | } |
110 | |
111 | #[repr (C)] |
112 | pub struct _GWin32InputStreamPrivate(c_void); |
113 | |
114 | pub type GWin32InputStreamPrivate = *mut _GWin32InputStreamPrivate; |
115 | |
116 | #[repr (C)] |
117 | #[derive (Copy, Clone)] |
118 | pub struct GWin32InputStream { |
119 | pub parent_instance: GInputStream, |
120 | pub priv_: *mut GWin32InputStreamPrivate, |
121 | } |
122 | |
123 | impl ::std::fmt::Debug for GWin32InputStream { |
124 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
125 | f.debug_struct(&format!("GWin32InputStream @ {:?}" , self as *const _)) |
126 | .field("parent_instance" , &self.parent_instance) |
127 | .finish() |
128 | } |
129 | } |
130 | |
131 | #[repr (C)] |
132 | #[derive (Copy, Clone)] |
133 | pub struct GWin32OutputStreamClass { |
134 | pub parent_class: GOutputStreamClass, |
135 | pub _g_reserved1: Option<unsafe extern "C" fn()>, |
136 | pub _g_reserved2: Option<unsafe extern "C" fn()>, |
137 | pub _g_reserved3: Option<unsafe extern "C" fn()>, |
138 | pub _g_reserved4: Option<unsafe extern "C" fn()>, |
139 | pub _g_reserved5: Option<unsafe extern "C" fn()>, |
140 | } |
141 | |
142 | impl ::std::fmt::Debug for GWin32OutputStreamClass { |
143 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
144 | f.debug_struct(&format!("GWin32OutputStreamClass @ {:?}" , self as *const _)) |
145 | .field("parent_class" , &self.parent_class) |
146 | .field("_g_reserved1" , &self._g_reserved1) |
147 | .field("_g_reserved2" , &self._g_reserved2) |
148 | .field("_g_reserved3" , &self._g_reserved3) |
149 | .field("_g_reserved4" , &self._g_reserved4) |
150 | .field("_g_reserved5" , &self._g_reserved5) |
151 | .finish() |
152 | } |
153 | } |
154 | |
155 | #[repr (C)] |
156 | pub struct _GWin32OutputStreamPrivate(c_void); |
157 | |
158 | pub type GWin32OutputStreamPrivate = *mut _GWin32OutputStreamPrivate; |
159 | |
160 | #[repr (C)] |
161 | #[derive (Copy, Clone)] |
162 | pub struct GWin32OutputStream { |
163 | pub parent_instance: GOutputStream, |
164 | pub priv_: *mut GWin32OutputStreamPrivate, |
165 | } |
166 | |
167 | impl ::std::fmt::Debug for GWin32OutputStream { |
168 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
169 | f.debug_struct(&format!("GWin32OutputStream @ {:?}" , self as *const _)) |
170 | .field("parent_instance" , &self.parent_instance) |
171 | .finish() |
172 | } |
173 | } |
174 | } |
175 | |
176 | #[cfg (not(feature = "v2_84" ))] |
177 | #[cfg (target_family = "unix" )] |
178 | mod unix_mount_compat { |
179 | #![allow (clippy::missing_safety_doc)] |
180 | |
181 | use crate::*; |
182 | |
183 | pub unsafe fn g_unix_mount_entry_compare( |
184 | mount1: *mut GUnixMountEntry, |
185 | mount2: *mut GUnixMountEntry, |
186 | ) -> c_int { |
187 | g_unix_mount_compare(mount1, mount2) |
188 | } |
189 | pub unsafe fn g_unix_mount_entry_copy( |
190 | mount_entry: *mut GUnixMountEntry, |
191 | ) -> *mut GUnixMountEntry { |
192 | g_unix_mount_copy(mount_entry) |
193 | } |
194 | pub unsafe fn g_unix_mount_entry_free(mount_entry: *mut GUnixMountEntry) { |
195 | g_unix_mount_free(mount_entry); |
196 | } |
197 | pub unsafe fn g_unix_mount_entry_get_device_path( |
198 | mount_entry: *mut GUnixMountEntry, |
199 | ) -> *const c_char { |
200 | g_unix_mount_get_device_path(mount_entry) |
201 | } |
202 | pub unsafe fn g_unix_mount_entry_get_fs_type( |
203 | mount_entry: *mut GUnixMountEntry, |
204 | ) -> *const c_char { |
205 | g_unix_mount_get_fs_type(mount_entry) |
206 | } |
207 | pub unsafe fn g_unix_mount_entry_get_mount_path( |
208 | mount_entry: *mut GUnixMountEntry, |
209 | ) -> *const c_char { |
210 | g_unix_mount_get_mount_path(mount_entry) |
211 | } |
212 | #[cfg (feature = "v2_58" )] |
213 | #[cfg_attr (docsrs, doc(cfg(feature = "v2_58" )))] |
214 | pub unsafe fn g_unix_mount_entry_get_options( |
215 | mount_entry: *mut GUnixMountEntry, |
216 | ) -> *const c_char { |
217 | g_unix_mount_get_options(mount_entry) |
218 | } |
219 | #[cfg (feature = "v2_60" )] |
220 | #[cfg_attr (docsrs, doc(cfg(feature = "v2_60" )))] |
221 | pub unsafe fn g_unix_mount_entry_get_root_path( |
222 | mount_entry: *mut GUnixMountEntry, |
223 | ) -> *const c_char { |
224 | g_unix_mount_get_root_path(mount_entry) |
225 | } |
226 | pub unsafe fn g_unix_mount_entry_guess_can_eject( |
227 | mount_entry: *mut GUnixMountEntry, |
228 | ) -> gboolean { |
229 | g_unix_mount_guess_can_eject(mount_entry) |
230 | } |
231 | pub unsafe fn g_unix_mount_entry_guess_icon(mount_entry: *mut GUnixMountEntry) -> *mut GIcon { |
232 | g_unix_mount_guess_icon(mount_entry) |
233 | } |
234 | pub unsafe fn g_unix_mount_entry_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char { |
235 | g_unix_mount_guess_name(mount_entry) |
236 | } |
237 | pub unsafe fn g_unix_mount_entry_guess_should_display( |
238 | mount_entry: *mut GUnixMountEntry, |
239 | ) -> gboolean { |
240 | g_unix_mount_guess_should_display(mount_entry) |
241 | } |
242 | pub unsafe fn g_unix_mount_entry_guess_symbolic_icon( |
243 | mount_entry: *mut GUnixMountEntry, |
244 | ) -> *mut GIcon { |
245 | g_unix_mount_guess_symbolic_icon(mount_entry) |
246 | } |
247 | pub unsafe fn g_unix_mount_entry_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean { |
248 | g_unix_mount_is_readonly(mount_entry) |
249 | } |
250 | pub unsafe fn g_unix_mount_entry_is_system_internal( |
251 | mount_entry: *mut GUnixMountEntry, |
252 | ) -> gboolean { |
253 | g_unix_mount_is_system_internal(mount_entry) |
254 | } |
255 | pub unsafe fn g_unix_mount_entry_at( |
256 | mount_path: *const c_char, |
257 | time_read: *mut u64, |
258 | ) -> *mut GUnixMountEntry { |
259 | g_unix_mount_at(mount_path, time_read) |
260 | } |
261 | pub unsafe fn g_unix_mount_entry_for( |
262 | file_path: *const c_char, |
263 | time_read: *mut u64, |
264 | ) -> *mut GUnixMountEntry { |
265 | g_unix_mount_for(file_path, time_read) |
266 | } |
267 | |
268 | #[cfg (feature = "v2_82" )] |
269 | #[cfg_attr (docsrs, doc(cfg(feature = "v2_82" )))] |
270 | pub unsafe fn g_unix_mount_entries_get_from_file( |
271 | table_path: *const c_char, |
272 | time_read_out: *mut u64, |
273 | n_entries_out: *mut size_t, |
274 | ) -> *mut *mut GUnixMountEntry { |
275 | g_unix_mounts_get_from_file(table_path, time_read_out, n_entries_out) |
276 | } |
277 | |
278 | pub unsafe fn g_unix_mount_entries_get(time_read: *mut u64) -> *mut glib::GList { |
279 | g_unix_mounts_get(time_read) |
280 | } |
281 | |
282 | pub unsafe fn g_unix_mount_entries_changed_since(time: u64) -> gboolean { |
283 | g_unix_mounts_changed_since(time) |
284 | } |
285 | } |
286 | |
287 | #[cfg (not(feature = "v2_84" ))] |
288 | #[cfg (target_family = "unix" )] |
289 | pub use unix_mount_compat::*; |
290 | |