gio_sys/
manual.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
// Take a look at the license at the top of the repository in the LICENSE file.

#[cfg(not(target_family = "windows"))]
pub use self::libc_constants::*;
#[cfg(target_family = "windows")]
pub use self::windows_constants::*;

pub type GSocketFamily = libc::c_int;
pub type GSocketMsgFlags = libc::c_int;

#[cfg(target_family = "windows")]
mod windows_constants {
    pub const G_SOCKET_FAMILY_INVALID: super::GSocketFamily =
        windows_sys::Win32::Networking::WinSock::AF_UNSPEC as super::GSocketFamily;
    pub const G_SOCKET_FAMILY_UNIX: super::GSocketFamily =
        windows_sys::Win32::Networking::WinSock::AF_UNIX as super::GSocketFamily;
    pub const G_SOCKET_FAMILY_IPV4: super::GSocketFamily =
        windows_sys::Win32::Networking::WinSock::AF_INET as super::GSocketFamily;
    pub const G_SOCKET_FAMILY_IPV6: super::GSocketFamily =
        windows_sys::Win32::Networking::WinSock::AF_INET6 as super::GSocketFamily;

    pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0;
    pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags =
        windows_sys::Win32::Networking::WinSock::MSG_OOB;
    pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags =
        windows_sys::Win32::Networking::WinSock::MSG_PEEK;
    pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags =
        windows_sys::Win32::Networking::WinSock::MSG_DONTROUTE;
}

#[cfg(not(target_family = "windows"))]
mod libc_constants {
    pub const G_SOCKET_FAMILY_INVALID: super::GSocketFamily = libc::AF_UNSPEC;
    pub const G_SOCKET_FAMILY_UNIX: super::GSocketFamily = libc::AF_UNIX;
    pub const G_SOCKET_FAMILY_IPV4: super::GSocketFamily = libc::AF_INET;
    pub const G_SOCKET_FAMILY_IPV6: super::GSocketFamily = libc::AF_INET6;

    pub const G_SOCKET_MSG_NONE: super::GSocketMsgFlags = 0;
    pub const G_SOCKET_MSG_OOB: super::GSocketMsgFlags = libc::MSG_OOB;
    pub const G_SOCKET_MSG_PEEK: super::GSocketMsgFlags = libc::MSG_PEEK;
    pub const G_SOCKET_MSG_DONTROUTE: super::GSocketMsgFlags = libc::MSG_DONTROUTE;
}

#[cfg(target_family = "windows")]
pub use self::windows_streams::*;

#[cfg(target_family = "windows")]
mod windows_streams {
    use libc::c_void;

    use crate::{
        gboolean, GInputStream, GInputStreamClass, GOutputStream, GOutputStreamClass, GType,
    };

    extern "C" {
        //=========================================================================
        // GWin32InputStream
        //=========================================================================
        pub fn g_win32_input_stream_get_type() -> GType;
        pub fn g_win32_input_stream_new(
            handle: *mut c_void,
            close_handle: gboolean,
        ) -> *mut GInputStream;
        pub fn g_win32_input_stream_get_close_handle(stream: *mut GWin32InputStream) -> gboolean;
        pub fn g_win32_input_stream_get_handle(stream: *mut GWin32InputStream) -> *mut c_void;
        pub fn g_win32_input_stream_set_close_handle(
            stream: *mut GWin32InputStream,
            close_handle: gboolean,
        );

        //=========================================================================
        // GWin32OutputStream
        //=========================================================================
        pub fn g_win32_output_stream_get_type() -> GType;
        pub fn g_win32_output_stream_new(
            handle: *mut c_void,
            close_handle: gboolean,
        ) -> *mut GOutputStream;
        pub fn g_win32_output_stream_get_close_handle(stream: *mut GWin32OutputStream) -> gboolean;
        pub fn g_win32_output_stream_get_handle(stream: *mut GWin32OutputStream) -> *mut c_void;
        pub fn g_win32_output_stream_set_close_handle(
            stream: *mut GWin32OutputStream,
            close_handle: gboolean,
        );
    }

    #[repr(C)]
    #[derive(Copy, Clone)]
    pub struct GWin32InputStreamClass {
        pub parent_class: GInputStreamClass,
        pub _g_reserved1: Option<unsafe extern "C" fn()>,
        pub _g_reserved2: Option<unsafe extern "C" fn()>,
        pub _g_reserved3: Option<unsafe extern "C" fn()>,
        pub _g_reserved4: Option<unsafe extern "C" fn()>,
        pub _g_reserved5: Option<unsafe extern "C" fn()>,
    }

    impl ::std::fmt::Debug for GWin32InputStreamClass {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            f.debug_struct(&format!("GWin32InputStreamClass @ {:?}", self as *const _))
                .field("parent_class", &self.parent_class)
                .field("_g_reserved1", &self._g_reserved1)
                .field("_g_reserved2", &self._g_reserved2)
                .field("_g_reserved3", &self._g_reserved3)
                .field("_g_reserved4", &self._g_reserved4)
                .field("_g_reserved5", &self._g_reserved5)
                .finish()
        }
    }

    #[repr(C)]
    pub struct _GWin32InputStreamPrivate(c_void);

    pub type GWin32InputStreamPrivate = *mut _GWin32InputStreamPrivate;

    #[repr(C)]
    #[derive(Copy, Clone)]
    pub struct GWin32InputStream {
        pub parent_instance: GInputStream,
        pub priv_: *mut GWin32InputStreamPrivate,
    }

    impl ::std::fmt::Debug for GWin32InputStream {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            f.debug_struct(&format!("GWin32InputStream @ {:?}", self as *const _))
                .field("parent_instance", &self.parent_instance)
                .finish()
        }
    }

    #[repr(C)]
    #[derive(Copy, Clone)]
    pub struct GWin32OutputStreamClass {
        pub parent_class: GOutputStreamClass,
        pub _g_reserved1: Option<unsafe extern "C" fn()>,
        pub _g_reserved2: Option<unsafe extern "C" fn()>,
        pub _g_reserved3: Option<unsafe extern "C" fn()>,
        pub _g_reserved4: Option<unsafe extern "C" fn()>,
        pub _g_reserved5: Option<unsafe extern "C" fn()>,
    }

    impl ::std::fmt::Debug for GWin32OutputStreamClass {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            f.debug_struct(&format!("GWin32OutputStreamClass @ {:?}", self as *const _))
                .field("parent_class", &self.parent_class)
                .field("_g_reserved1", &self._g_reserved1)
                .field("_g_reserved2", &self._g_reserved2)
                .field("_g_reserved3", &self._g_reserved3)
                .field("_g_reserved4", &self._g_reserved4)
                .field("_g_reserved5", &self._g_reserved5)
                .finish()
        }
    }

    #[repr(C)]
    pub struct _GWin32OutputStreamPrivate(c_void);

    pub type GWin32OutputStreamPrivate = *mut _GWin32OutputStreamPrivate;

    #[repr(C)]
    #[derive(Copy, Clone)]
    pub struct GWin32OutputStream {
        pub parent_instance: GOutputStream,
        pub priv_: *mut GWin32OutputStreamPrivate,
    }

    impl ::std::fmt::Debug for GWin32OutputStream {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            f.debug_struct(&format!("GWin32OutputStream @ {:?}", self as *const _))
                .field("parent_instance", &self.parent_instance)
                .finish()
        }
    }
}

#[cfg(not(feature = "v2_84"))]
#[cfg(target_family = "unix")]
mod unix_mount_compat {
    #![allow(clippy::missing_safety_doc)]

    use crate::*;

    pub unsafe fn g_unix_mount_entry_compare(
        mount1: *mut GUnixMountEntry,
        mount2: *mut GUnixMountEntry,
    ) -> c_int {
        g_unix_mount_compare(mount1, mount2)
    }
    pub unsafe fn g_unix_mount_entry_copy(
        mount_entry: *mut GUnixMountEntry,
    ) -> *mut GUnixMountEntry {
        g_unix_mount_copy(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_free(mount_entry: *mut GUnixMountEntry) {
        g_unix_mount_free(mount_entry);
    }
    pub unsafe fn g_unix_mount_entry_get_device_path(
        mount_entry: *mut GUnixMountEntry,
    ) -> *const c_char {
        g_unix_mount_get_device_path(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_get_fs_type(
        mount_entry: *mut GUnixMountEntry,
    ) -> *const c_char {
        g_unix_mount_get_fs_type(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_get_mount_path(
        mount_entry: *mut GUnixMountEntry,
    ) -> *const c_char {
        g_unix_mount_get_mount_path(mount_entry)
    }
    #[cfg(feature = "v2_58")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
    pub unsafe fn g_unix_mount_entry_get_options(
        mount_entry: *mut GUnixMountEntry,
    ) -> *const c_char {
        g_unix_mount_get_options(mount_entry)
    }
    #[cfg(feature = "v2_60")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
    pub unsafe fn g_unix_mount_entry_get_root_path(
        mount_entry: *mut GUnixMountEntry,
    ) -> *const c_char {
        g_unix_mount_get_root_path(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_guess_can_eject(
        mount_entry: *mut GUnixMountEntry,
    ) -> gboolean {
        g_unix_mount_guess_can_eject(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_guess_icon(mount_entry: *mut GUnixMountEntry) -> *mut GIcon {
        g_unix_mount_guess_icon(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_guess_name(mount_entry: *mut GUnixMountEntry) -> *mut c_char {
        g_unix_mount_guess_name(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_guess_should_display(
        mount_entry: *mut GUnixMountEntry,
    ) -> gboolean {
        g_unix_mount_guess_should_display(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_guess_symbolic_icon(
        mount_entry: *mut GUnixMountEntry,
    ) -> *mut GIcon {
        g_unix_mount_guess_symbolic_icon(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_is_readonly(mount_entry: *mut GUnixMountEntry) -> gboolean {
        g_unix_mount_is_readonly(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_is_system_internal(
        mount_entry: *mut GUnixMountEntry,
    ) -> gboolean {
        g_unix_mount_is_system_internal(mount_entry)
    }
    pub unsafe fn g_unix_mount_entry_at(
        mount_path: *const c_char,
        time_read: *mut u64,
    ) -> *mut GUnixMountEntry {
        g_unix_mount_at(mount_path, time_read)
    }
    pub unsafe fn g_unix_mount_entry_for(
        file_path: *const c_char,
        time_read: *mut u64,
    ) -> *mut GUnixMountEntry {
        g_unix_mount_for(file_path, time_read)
    }

    #[cfg(feature = "v2_82")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))]
    pub unsafe fn g_unix_mount_entries_get_from_file(
        table_path: *const c_char,
        time_read_out: *mut u64,
        n_entries_out: *mut size_t,
    ) -> *mut *mut GUnixMountEntry {
        g_unix_mounts_get_from_file(table_path, time_read_out, n_entries_out)
    }

    pub unsafe fn g_unix_mount_entries_get(time_read: *mut u64) -> *mut glib::GList {
        g_unix_mounts_get(time_read)
    }

    pub unsafe fn g_unix_mount_entries_changed_since(time: u64) -> gboolean {
        g_unix_mounts_changed_since(time)
    }
}

#[cfg(not(feature = "v2_84"))]
#[cfg(target_family = "unix")]
pub use unix_mount_compat::*;