glib_sys/
manual.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3#[cfg(unix)]
4pub use libc::passwd;
5#[allow(unused_imports)]
6use libc::{c_char, c_int, c_ushort, c_void};
7
8pub use libc::c_int as gint;
9pub use libc::c_uint as guint;
10
11pub type GType = libc::size_t;
12
13#[cfg(all(not(unix), docsrs))]
14#[repr(C)]
15pub struct passwd {
16    pw_name: *mut c_char,
17    pw_passwd: *mut c_char,
18    pw_uid: u32,
19    pw_gid: u32,
20    pw_gecos: *mut c_char,
21    pw_dir: *mut c_char,
22    pw_shell: *mut c_char,
23}
24
25#[cfg(windows)]
26pub type GPid = *mut c_void;
27
28#[cfg(not(windows))]
29pub type GPid = libc::pid_t;
30
31#[repr(C)]
32#[derive(Copy, Clone)]
33#[cfg(all(windows, target_arch = "x86_64"))]
34pub struct GPollFD {
35    pub fd: i64,
36    pub events: c_ushort,
37    pub revents: c_ushort,
38}
39
40#[repr(C)]
41#[derive(Copy, Clone)]
42#[cfg(not(all(windows, target_arch = "x86_64")))]
43pub struct GPollFD {
44    pub fd: c_int,
45    pub events: c_ushort,
46    pub revents: c_ushort,
47}
48
49// These are all non-NUL terminated strings in C
50pub const G_VARIANT_TYPE_BOOLEAN: &str = "b";
51pub const G_VARIANT_TYPE_BYTE: &str = "y";
52pub const G_VARIANT_TYPE_INT16: &str = "n";
53pub const G_VARIANT_TYPE_UINT16: &str = "q";
54pub const G_VARIANT_TYPE_INT32: &str = "i";
55pub const G_VARIANT_TYPE_UINT32: &str = "u";
56pub const G_VARIANT_TYPE_INT64: &str = "x";
57pub const G_VARIANT_TYPE_UINT64: &str = "t";
58pub const G_VARIANT_TYPE_DOUBLE: &str = "d";
59pub const G_VARIANT_TYPE_STRING: &str = "s";
60pub const G_VARIANT_TYPE_OBJECT_PATH: &str = "o";
61pub const G_VARIANT_TYPE_SIGNATURE: &str = "g";
62pub const G_VARIANT_TYPE_VARIANT: &str = "v";
63pub const G_VARIANT_TYPE_HANDLE: &str = "h";
64pub const G_VARIANT_TYPE_UNIT: &str = "()";
65pub const G_VARIANT_TYPE_ANY: &str = "*";
66pub const G_VARIANT_TYPE_BASIC: &str = "?";
67pub const G_VARIANT_TYPE_MAYBE: &str = "m*";
68pub const G_VARIANT_TYPE_ARRAY: &str = "a*";
69pub const G_VARIANT_TYPE_TUPLE: &str = "r";
70pub const G_VARIANT_TYPE_DICT_ENTRY: &str = "{?*}";
71pub const G_VARIANT_TYPE_DICTIONARY: &str = "a{?*}";
72pub const G_VARIANT_TYPE_STRING_ARRAY: &str = "as";
73pub const G_VARIANT_TYPE_OBJECT_PATH_ARRAY: &str = "ao";
74pub const G_VARIANT_TYPE_BYTE_STRING: &str = "ay";
75pub const G_VARIANT_TYPE_BYTE_STRING_ARRAY: &str = "aay";
76pub const G_VARIANT_TYPE_VARDICT: &str = "a{sv}";
77
78#[cfg(target_family = "windows")]
79pub use self::win32::*;
80
81#[cfg(target_family = "windows")]
82mod win32 {
83    use libc::{c_char, c_int, c_uint};
84
85    pub type GWin32OSType = c_int;
86    pub const G_WIN32_OS_ANY: GWin32OSType = 0;
87    pub const G_WIN32_OS_WORKSTATION: GWin32OSType = 1;
88    pub const G_WIN32_OS_SERVER: GWin32OSType = 2;
89
90    extern "C" {
91        pub fn g_win32_check_windows_version(
92            major: c_int,
93            minor: c_int,
94            spver: c_int,
95            os_type: GWin32OSType,
96        ) -> crate::gboolean;
97
98        pub fn g_win32_get_command_line() -> *mut *mut c_char;
99
100        pub fn g_win32_error_message(error: c_int) -> *mut c_char;
101
102        pub fn g_win32_getlocale() -> *mut c_char;
103
104        pub fn g_win32_get_package_installation_directory_of_module(
105            hmodule: std::os::windows::raw::HANDLE,
106        ) -> *mut c_char;
107
108        pub fn g_win32_locale_filename_from_utf8(utf8filename: *const c_char) -> *mut c_char;
109
110        pub fn g_win32_ftruncate(f: c_int, size: c_uint) -> c_int;
111        pub fn g_win32_get_package_installation_directory(
112            package: *const c_char,
113            dll_name: *const c_char,
114        ) -> *mut c_char;
115        pub fn g_win32_get_package_installation_subdirectory(
116            package: *const c_char,
117            dll_name: *const c_char,
118            subdir: *const c_char,
119        ) -> *mut c_char;
120        pub fn g_win32_get_windows_version() -> c_uint;
121    }
122}
123
124extern "C" {
125    pub fn g_atomic_int_get(atomic: *const c_int) -> c_int;
126}