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
// 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()
        }
    }
}