diff options
Diffstat (limited to 'libsecret/sys')
-rw-r--r-- | libsecret/sys/.cargo_vcs_info.json | 6 | ||||
-rw-r--r-- | libsecret/sys/Cargo.toml | 110 | ||||
-rw-r--r-- | libsecret/sys/Cargo.toml.orig | 76 | ||||
-rw-r--r-- | libsecret/sys/Gir.toml | 17 | ||||
-rw-r--r-- | libsecret/sys/README.md | 10 | ||||
-rw-r--r-- | libsecret/sys/build.rs | 18 | ||||
-rw-r--r-- | libsecret/sys/src/lib.rs | 1769 | ||||
-rw-r--r-- | libsecret/sys/tests/abi.rs | 405 | ||||
-rw-r--r-- | libsecret/sys/tests/constant.c | 69 | ||||
-rw-r--r-- | libsecret/sys/tests/layout.c | 35 | ||||
-rw-r--r-- | libsecret/sys/tests/manual.h | 3 |
11 files changed, 2518 insertions, 0 deletions
diff --git a/libsecret/sys/.cargo_vcs_info.json b/libsecret/sys/.cargo_vcs_info.json new file mode 100644 index 0000000..038c98b --- /dev/null +++ b/libsecret/sys/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "124286ef3e4c68d8bb2d0f852fcc77d9a2f5229b" + }, + "path_in_vcs": "libsecret/sys" +} \ No newline at end of file diff --git a/libsecret/sys/Cargo.toml b/libsecret/sys/Cargo.toml new file mode 100644 index 0000000..5ed8b41 --- /dev/null +++ b/libsecret/sys/Cargo.toml @@ -0,0 +1,110 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +name = "libsecret-sys" +version = "0.6.0" +build = "build.rs" +links = "secret" +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "ffi bindings of libsecret" +homepage = "https://world.pages.gitlab.gnome.org/Rust/libsecret-rs" +documentation = "https://world.pages.gitlab.gnome.org/Rust/libsecret-rs/stable/latest/docs/libsecret_sys" +readme = "README.md" +keywords = [ + "libsecret", + "dbus", + "secret", + "bindings", + "freedesktop", +] +categories = ["api-bindings"] +license = "MIT" +repository = "https://gitlab.gnome.org/World/Rust/libsecret-rs" + +[package.metadata.docs.rs] +features = [] +rustc-args = [ + "--cfg", + "docsrs", +] +rustdoc-args = [ + "--cfg", + "docsrs", + "--generate-link-to-definition", +] + +[package.metadata.system-deps.libsecret_1] +name = "libsecret-1" +version = "0.0" + +[package.metadata.system-deps.libsecret_1.v0_18] +version = "0.18" + +[package.metadata.system-deps.libsecret_1.v0_18_6] +version = "0.18.6" + +[package.metadata.system-deps.libsecret_1.v0_19] +version = "0.19" + +[package.metadata.system-deps.libsecret_1.v0_20] +version = "0.20" + +[package.metadata.system-deps.libsecret_1.v0_21] +version = "0.21" + +[package.metadata.system-deps.libsecret_1.v0_21_2] +version = "0.21.2" + +[lib] +name = "libsecret_sys" +path = "src/lib.rs" + +[[test]] +name = "abi" +path = "tests/abi.rs" + +[dependencies.gio-sys] +version = "0.20" + +[dependencies.glib-sys] +version = "0.20" + +[dependencies.gobject-sys] +version = "0.20" + +[dependencies.libc] +version = "0.2" + +[dev-dependencies.shell-words] +version = "1.0.0" + +[dev-dependencies.tempfile] +version = "3" + +[build-dependencies.pkg-config] +version = "0.3.7" + +[build-dependencies.system-deps] +version = "6" + +[features] +default = ["v0_18"] +v0_18 = [] +v0_18_6 = [] +v0_19 = ["v0_18_6"] +v0_20 = ["v0_19"] +v0_21 = ["v0_20"] +v0_21_2 = ["v0_21"] diff --git a/libsecret/sys/Cargo.toml.orig b/libsecret/sys/Cargo.toml.orig new file mode 100644 index 0000000..a3b0a0f --- /dev/null +++ b/libsecret/sys/Cargo.toml.orig @@ -0,0 +1,76 @@ +[package] +name = "libsecret-sys" +version = "0.6.0" +links = "secret" +build = "build.rs" +edition = "2021" +readme = "../../README.md" +license = "MIT" +repository = "https://gitlab.gnome.org/World/Rust/libsecret-rs" +documentation = "https://world.pages.gitlab.gnome.org/Rust/libsecret-rs/stable/latest/docs/libsecret_sys" +categories = ["api-bindings"] +description = "ffi bindings of libsecret" +homepage = "https://world.pages.gitlab.gnome.org/Rust/libsecret-rs" +keywords = ["libsecret", "dbus", "secret", "bindings", "freedesktop"] + +[package.metadata.docs.rs] +features = [] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] + +[package.metadata.system-deps.libsecret_1] +name = "libsecret-1" +version = "0.0" + +[package.metadata.system-deps.libsecret_1.v0_18] +version = "0.18" + +[package.metadata.system-deps.libsecret_1.v0_19] +version = "0.19" + +[package.metadata.system-deps.libsecret_1.v0_20] +version = "0.20" + +[package.metadata.system-deps.libsecret_1.v0_21] +version = "0.21" + +[package.metadata.system-deps.libsecret_1.v0_18_6] +version = "0.18.6" + +[package.metadata.system-deps.libsecret_1.v0_21_2] +version = "0.21.2" + +[dependencies] +libc = "0.2" + +[dependencies.gio-sys] +git = "https://github.com/gtk-rs/gtk-rs-core" +version = "0.20" +tag = "0.20.4" + +[dependencies.glib-sys] +git = "https://github.com/gtk-rs/gtk-rs-core" +version = "0.20" +tag = "0.20.4" + +[dependencies.gobject-sys] +git = "https://github.com/gtk-rs/gtk-rs-core" +version = "0.20" +tag = "0.20.4" + +[build-dependencies] +pkg-config = "0.3.7" +system-deps = "6" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] +default = ["v0_18"] +v0_18 = [] +v0_19 = ["v0_18_6"] +v0_20 = ["v0_19"] +v0_21 = ["v0_20"] +v0_18_6 = [] +v0_21_2 = ["v0_21"] diff --git a/libsecret/sys/Gir.toml b/libsecret/sys/Gir.toml new file mode 100644 index 0000000..772ef3c --- /dev/null +++ b/libsecret/sys/Gir.toml @@ -0,0 +1,17 @@ +[options] +work_mode = "sys" +library = "Secret" +version = "1" +girs_directories = ["../../gir-files", "../../"] +min_cfg_version = "0.1" +external_libraries = [ + "GLib", + "GObject", + "Gio", +] + +ignore = [ + "Secret.MAJOR_VERSION", + "Secret.MICRO_VERSION", + "Secret.MINOR_VERSION", +] \ No newline at end of file diff --git a/libsecret/sys/README.md b/libsecret/sys/README.md new file mode 100644 index 0000000..9a47559 --- /dev/null +++ b/libsecret/sys/README.md @@ -0,0 +1,10 @@ +# libsecret-rs + +The Rust bindings of [libsecret](https://gitlab.gnome.org/GNOME/libsecret). + +- Website: <https://gitlab.gnome.org/World/Rust/libsecret-rs/> + +# Documentation + +- libsecret: <https://world.pages.gitlab.gnome.org/Rust/libsecret-rs/stable/latest/docs/libsecret> +- libsecret_sys: <https://world.pages.gitlab.gnome.org/Rust/libsecret-rs/stable/latest/docs/libsecret_sys> diff --git a/libsecret/sys/build.rs b/libsecret/sys/build.rs new file mode 100644 index 0000000..fc0010a --- /dev/null +++ b/libsecret/sys/build.rs @@ -0,0 +1,18 @@ +// Generated by gir (https://github.com/gtk-rs/gir @ 4dd714f7f3b1) +// from +// from gir-files (https://github.com/gtk-rs/gir-files.git @ b9db716f1bb7) +// DO NOT EDIT + +#[cfg(not(docsrs))] +use std::process; + +#[cfg(docsrs)] +fn main() {} // prevent linking libraries to avoid documentation failure + +#[cfg(not(docsrs))] +fn main() { + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + process::exit(1); + } +} diff --git a/libsecret/sys/src/lib.rs b/libsecret/sys/src/lib.rs new file mode 100644 index 0000000..6f473ca --- /dev/null +++ b/libsecret/sys/src/lib.rs @@ -0,0 +1,1769 @@ +// Generated by gir (https://github.com/gtk-rs/gir @ 4dd714f7f3b1) +// from +// from gir-files (https://github.com/gtk-rs/gir-files.git @ b9db716f1bb7) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use gio_sys as gio; +use glib_sys as glib; +use gobject_sys as gobject; + +#[allow(unused_imports)] +use libc::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, + intptr_t, size_t, ssize_t, uintptr_t, FILE, +}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Enums +pub type SecretBackendFlags = c_int; +pub const SECRET_BACKEND_NONE: SecretBackendFlags = 0; +pub const SECRET_BACKEND_OPEN_SESSION: SecretBackendFlags = 2; +pub const SECRET_BACKEND_LOAD_COLLECTIONS: SecretBackendFlags = 4; + +pub type SecretError = c_int; +pub const SECRET_ERROR_PROTOCOL: SecretError = 1; +pub const SECRET_ERROR_IS_LOCKED: SecretError = 2; +pub const SECRET_ERROR_NO_SUCH_OBJECT: SecretError = 3; +pub const SECRET_ERROR_ALREADY_EXISTS: SecretError = 4; +pub const SECRET_ERROR_INVALID_FILE_FORMAT: SecretError = 5; +#[cfg(feature = "v0_21_2")] +#[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] +pub const SECRET_ERROR_MISMATCHED_SCHEMA: SecretError = 6; +#[cfg(feature = "v0_21_2")] +#[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] +pub const SECRET_ERROR_NO_MATCHING_ATTRIBUTE: SecretError = 7; +#[cfg(feature = "v0_21_2")] +#[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] +pub const SECRET_ERROR_WRONG_TYPE: SecretError = 8; +#[cfg(feature = "v0_21_2")] +#[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] +pub const SECRET_ERROR_EMPTY_TABLE: SecretError = 9; + +pub type SecretSchemaAttributeType = c_int; +pub const SECRET_SCHEMA_ATTRIBUTE_STRING: SecretSchemaAttributeType = 0; +pub const SECRET_SCHEMA_ATTRIBUTE_INTEGER: SecretSchemaAttributeType = 1; +pub const SECRET_SCHEMA_ATTRIBUTE_BOOLEAN: SecretSchemaAttributeType = 2; + +pub type SecretSchemaType = c_int; +pub const SECRET_SCHEMA_TYPE_NOTE: SecretSchemaType = 0; +pub const SECRET_SCHEMA_TYPE_COMPAT_NETWORK: SecretSchemaType = 1; + +// Constants +pub const SECRET_BACKEND_EXTENSION_POINT_NAME: &[u8] = b"secret-backend\0"; +pub const SECRET_COLLECTION_DEFAULT: &[u8] = b"default\0"; +pub const SECRET_COLLECTION_SESSION: &[u8] = b"session\0"; + +// Flags +pub type SecretCollectionCreateFlags = c_uint; +pub const SECRET_COLLECTION_CREATE_NONE: SecretCollectionCreateFlags = 0; + +pub type SecretCollectionFlags = c_uint; +pub const SECRET_COLLECTION_NONE: SecretCollectionFlags = 0; +pub const SECRET_COLLECTION_LOAD_ITEMS: SecretCollectionFlags = 2; + +pub type SecretItemCreateFlags = c_uint; +pub const SECRET_ITEM_CREATE_NONE: SecretItemCreateFlags = 0; +pub const SECRET_ITEM_CREATE_REPLACE: SecretItemCreateFlags = 2; + +pub type SecretItemFlags = c_uint; +pub const SECRET_ITEM_NONE: SecretItemFlags = 0; +pub const SECRET_ITEM_LOAD_SECRET: SecretItemFlags = 2; + +pub type SecretSchemaFlags = c_uint; +pub const SECRET_SCHEMA_NONE: SecretSchemaFlags = 0; +pub const SECRET_SCHEMA_DONT_MATCH_NAME: SecretSchemaFlags = 2; + +pub type SecretSearchFlags = c_uint; +pub const SECRET_SEARCH_NONE: SecretSearchFlags = 0; +pub const SECRET_SEARCH_ALL: SecretSearchFlags = 2; +pub const SECRET_SEARCH_UNLOCK: SecretSearchFlags = 4; +pub const SECRET_SEARCH_LOAD_SECRETS: SecretSearchFlags = 8; + +pub type SecretServiceFlags = c_uint; +pub const SECRET_SERVICE_NONE: SecretServiceFlags = 0; +pub const SECRET_SERVICE_OPEN_SESSION: SecretServiceFlags = 2; +pub const SECRET_SERVICE_LOAD_COLLECTIONS: SecretServiceFlags = 4; + +// Records +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretBackendInterface { + pub parent_iface: gobject::GTypeInterface, + pub ensure_for_flags: Option< + unsafe extern "C" fn( + *mut SecretBackend, + SecretBackendFlags, + *mut gio::GCancellable, + gio::GAsyncReadyCallback, + gpointer, + ), + >, + pub ensure_for_flags_finish: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *mut gio::GAsyncResult, + *mut *mut glib::GError, + ) -> gboolean, + >, + pub store: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *const SecretSchema, + *mut glib::GHashTable, + *const c_char, + *const c_char, + *mut SecretValue, + *mut gio::GCancellable, + gio::GAsyncReadyCallback, + gpointer, + ), + >, + pub store_finish: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *mut gio::GAsyncResult, + *mut *mut glib::GError, + ) -> gboolean, + >, + pub lookup: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *const SecretSchema, + *mut glib::GHashTable, + *mut gio::GCancellable, + gio::GAsyncReadyCallback, + gpointer, + ), + >, + pub lookup_finish: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *mut gio::GAsyncResult, + *mut *mut glib::GError, + ) -> *mut SecretValue, + >, + pub clear: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *const SecretSchema, + *mut glib::GHashTable, + *mut gio::GCancellable, + gio::GAsyncReadyCallback, + gpointer, + ), + >, + pub clear_finish: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *mut gio::GAsyncResult, + *mut *mut glib::GError, + ) -> gboolean, + >, + pub search: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *const SecretSchema, + *mut glib::GHashTable, + SecretSearchFlags, + *mut gio::GCancellable, + gio::GAsyncReadyCallback, + gpointer, + ), + >, + pub search_finish: Option< + unsafe extern "C" fn( + *mut SecretBackend, + *mut gio::GAsyncResult, + *mut *mut glib::GError, + ) -> *mut glib::GList, + >, +} + +impl ::std::fmt::Debug for SecretBackendInterface { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretBackendInterface @ {self:p}")) + .field("parent_iface", &self.parent_iface) + .field("ensure_for_flags", &self.ensure_for_flags) + .field("ensure_for_flags_finish", &self.ensure_for_flags_finish) + .field("store", &self.store) + .field("store_finish", &self.store_finish) + .field("lookup", &self.lookup) + .field("lookup_finish", &self.lookup_finish) + .field("clear", &self.clear) + .field("clear_finish", &self.clear_finish) + .field("search", &self.search) + .field("search_finish", &self.search_finish) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretCollectionClass { + pub parent_class: gio::GDBusProxyClass, + pub padding: [gpointer; 8], +} + +impl ::std::fmt::Debug for SecretCollectionClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretCollectionClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _SecretCollectionPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type SecretCollectionPrivate = _SecretCollectionPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretItemClass { + pub parent_class: gio::GDBusProxyClass, + pub padding: [gpointer; 4], +} + +impl ::std::fmt::Debug for SecretItemClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretItemClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _SecretItemPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type SecretItemPrivate = _SecretItemPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretPromptClass { + pub parent_class: gio::GDBusProxyClass, + pub padding: [gpointer; 8], +} + +impl ::std::fmt::Debug for SecretPromptClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretPromptClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _SecretPromptPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type SecretPromptPrivate = _SecretPromptPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretRetrievableInterface { + pub parent_iface: gobject::GTypeInterface, + pub retrieve_secret: Option< + unsafe extern "C" fn( + *mut SecretRetrievable, + *mut gio::GCancellable, + gio::GAsyncReadyCallback, + gpointer, + ), + >, + pub retrieve_secret_finish: Option< + unsafe extern "C" fn( + *mut SecretRetrievable, + *mut gio::GAsyncResult, + *mut *mut glib::GError, + ) -> *mut SecretValue, + >, +} + +impl ::std::fmt::Debug for SecretRetrievableInterface { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretRetrievableInterface @ {self:p}")) + .field("parent_iface", &self.parent_iface) + .field("retrieve_secret", &self.retrieve_secret) + .field("retrieve_secret_finish", &self.retrieve_secret_finish) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretSchema { + pub name: *const c_char, + pub flags: SecretSchemaFlags, + pub attributes: [SecretSchemaAttribute; 32], + pub reserved: c_int, + pub reserved1: gpointer, + pub reserved2: gpointer, + pub reserved3: gpointer, + pub reserved4: gpointer, + pub reserved5: gpointer, + pub reserved6: gpointer, + pub reserved7: gpointer, +} + +impl ::std::fmt::Debug for SecretSchema { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretSchema @ {self:p}")) + .field("name", &self.name) + .field("flags", &self.flags) + .field("attributes", &self.attributes) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretSchemaAttribute { + pub name: *const c_char, + pub type_: SecretSchemaAttributeType, +} + +impl ::std::fmt::Debug for SecretSchemaAttribute { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretSchemaAttribute @ {self:p}")) + .field("name", &self.name) + .field("type_", &self.type_) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretServiceClass { + pub parent_class: gio::GDBusProxyClass, + pub collection_gtype: GType, + pub item_gtype: GType, + pub prompt_sync: Option< + unsafe extern "C" fn( + *mut SecretService, + *mut SecretPrompt, + *mut gio::GCancellable, + *const glib::GVariantType, + *mut *mut glib::GError, + ) -> *mut glib::GVariant, + >, + pub prompt_async: Option< + unsafe extern "C" fn( + *mut SecretService, + *mut SecretPrompt, + *const glib::GVariantType, + *mut gio::GCancellable, + gio::GAsyncReadyCallback, + gpointer, + ), + >, + pub prompt_finish: Option< + unsafe extern "C" fn( + *mut SecretService, + *mut gio::GAsyncResult, + *mut *mut glib::GError, + ) -> *mut glib::GVariant, + >, + pub get_collection_gtype: Option<unsafe extern "C" fn(*mut SecretService) -> GType>, + pub get_item_gtype: Option<unsafe extern "C" fn(*mut SecretService) -> GType>, + pub padding: [gpointer; 14], +} + +impl ::std::fmt::Debug for SecretServiceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretServiceClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("collection_gtype", &self.collection_gtype) + .field("item_gtype", &self.item_gtype) + .field("prompt_sync", &self.prompt_sync) + .field("prompt_async", &self.prompt_async) + .field("prompt_finish", &self.prompt_finish) + .field("get_collection_gtype", &self.get_collection_gtype) + .field("get_item_gtype", &self.get_item_gtype) + .finish() + } +} + +#[repr(C)] +pub struct _SecretServicePrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type SecretServicePrivate = _SecretServicePrivate; + +#[repr(C)] +pub struct SecretValue { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for SecretValue { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretValue @ {self:p}")).finish() + } +} + +// Classes +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretCollection { + pub parent: gio::GDBusProxy, + pub pv: *mut SecretCollectionPrivate, +} + +impl ::std::fmt::Debug for SecretCollection { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretCollection @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretItem { + pub parent_instance: gio::GDBusProxy, + pub pv: *mut SecretItemPrivate, +} + +impl ::std::fmt::Debug for SecretItem { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretItem @ {self:p}")) + .field("parent_instance", &self.parent_instance) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretPrompt { + pub parent_instance: gio::GDBusProxy, + pub pv: *mut SecretPromptPrivate, +} + +impl ::std::fmt::Debug for SecretPrompt { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretPrompt @ {self:p}")) + .field("parent_instance", &self.parent_instance) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct SecretService { + pub parent: gio::GDBusProxy, + pub pv: *mut SecretServicePrivate, +} + +impl ::std::fmt::Debug for SecretService { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("SecretService @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +// Interfaces +#[repr(C)] +pub struct SecretBackend { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for SecretBackend { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(f, "SecretBackend @ {self:p}") + } +} + +#[repr(C)] +pub struct SecretRetrievable { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for SecretRetrievable { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(f, "SecretRetrievable @ {self:p}") + } +} + +#[link(name = "secret-1")] +extern "C" { + + //========================================================================= + // SecretBackendFlags + //========================================================================= + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_backend_flags_get_type() -> GType; + + //========================================================================= + // SecretError + //========================================================================= + pub fn secret_error_get_type() -> GType; + pub fn secret_error_get_quark() -> glib::GQuark; + + //========================================================================= + // SecretSchemaAttributeType + //========================================================================= + pub fn secret_schema_attribute_type_get_type() -> GType; + + //========================================================================= + // SecretSchemaType + //========================================================================= + #[cfg(feature = "v0_18_6")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] + pub fn secret_schema_type_get_type() -> GType; + + //========================================================================= + // SecretCollectionCreateFlags + //========================================================================= + pub fn secret_collection_create_flags_get_type() -> GType; + + //========================================================================= + // SecretCollectionFlags + //========================================================================= + pub fn secret_collection_flags_get_type() -> GType; + + //========================================================================= + // SecretItemCreateFlags + //========================================================================= + pub fn secret_item_create_flags_get_type() -> GType; + + //========================================================================= + // SecretItemFlags + //========================================================================= + pub fn secret_item_flags_get_type() -> GType; + + //========================================================================= + // SecretSchemaFlags + //========================================================================= + pub fn secret_schema_flags_get_type() -> GType; + + //========================================================================= + // SecretSearchFlags + //========================================================================= + pub fn secret_search_flags_get_type() -> GType; + + //========================================================================= + // SecretServiceFlags + //========================================================================= + pub fn secret_service_flags_get_type() -> GType; + + //========================================================================= + // SecretSchema + //========================================================================= + pub fn secret_schema_get_type() -> GType; + pub fn secret_schema_new( + name: *const c_char, + flags: SecretSchemaFlags, + ... + ) -> *mut SecretSchema; + pub fn secret_schema_newv( + name: *const c_char, + flags: SecretSchemaFlags, + attribute_names_and_types: *mut glib::GHashTable, + ) -> *mut SecretSchema; + pub fn secret_schema_ref(schema: *mut SecretSchema) -> *mut SecretSchema; + pub fn secret_schema_unref(schema: *mut SecretSchema); + + //========================================================================= + // SecretSchemaAttribute + //========================================================================= + pub fn secret_schema_attribute_get_type() -> GType; + + //========================================================================= + // SecretValue + //========================================================================= + pub fn secret_value_get_type() -> GType; + pub fn secret_value_new( + secret: *const c_char, + length: ssize_t, + content_type: *const c_char, + ) -> *mut SecretValue; + pub fn secret_value_new_full( + secret: *mut c_char, + length: ssize_t, + content_type: *const c_char, + destroy: glib::GDestroyNotify, + ) -> *mut SecretValue; + pub fn secret_value_get(value: *mut SecretValue, length: *mut size_t) -> *const u8; + pub fn secret_value_get_content_type(value: *mut SecretValue) -> *const c_char; + pub fn secret_value_get_text(value: *mut SecretValue) -> *const c_char; + pub fn secret_value_ref(value: *mut SecretValue) -> *mut SecretValue; + pub fn secret_value_unref(value: gpointer); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_value_unref_to_password( + value: *mut SecretValue, + length: *mut size_t, + ) -> *mut c_char; + + //========================================================================= + // SecretCollection + //========================================================================= + pub fn secret_collection_get_type() -> GType; + pub fn secret_collection_new_for_dbus_path_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretCollection; + pub fn secret_collection_new_for_dbus_path_sync( + service: *mut SecretService, + collection_path: *const c_char, + flags: SecretCollectionFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretCollection; + pub fn secret_collection_create( + service: *mut SecretService, + label: *const c_char, + alias: *const c_char, + flags: SecretCollectionCreateFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_collection_create_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretCollection; + pub fn secret_collection_create_sync( + service: *mut SecretService, + label: *const c_char, + alias: *const c_char, + flags: SecretCollectionCreateFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretCollection; + pub fn secret_collection_for_alias( + service: *mut SecretService, + alias: *const c_char, + flags: SecretCollectionFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_collection_for_alias_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretCollection; + pub fn secret_collection_for_alias_sync( + service: *mut SecretService, + alias: *const c_char, + flags: SecretCollectionFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretCollection; + pub fn secret_collection_new_for_dbus_path( + service: *mut SecretService, + collection_path: *const c_char, + flags: SecretCollectionFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_collection_delete( + self_: *mut SecretCollection, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_collection_delete_finish( + self_: *mut SecretCollection, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_collection_delete_sync( + self_: *mut SecretCollection, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_collection_get_created(self_: *mut SecretCollection) -> u64; + pub fn secret_collection_get_flags(self_: *mut SecretCollection) -> SecretCollectionFlags; + pub fn secret_collection_get_items(self_: *mut SecretCollection) -> *mut glib::GList; + pub fn secret_collection_get_label(self_: *mut SecretCollection) -> *mut c_char; + pub fn secret_collection_get_locked(self_: *mut SecretCollection) -> gboolean; + pub fn secret_collection_get_modified(self_: *mut SecretCollection) -> u64; + pub fn secret_collection_get_service(self_: *mut SecretCollection) -> *mut SecretService; + pub fn secret_collection_load_items( + self_: *mut SecretCollection, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_collection_load_items_finish( + self_: *mut SecretCollection, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_collection_load_items_sync( + self_: *mut SecretCollection, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_collection_refresh(self_: *mut SecretCollection); + pub fn secret_collection_search( + self_: *mut SecretCollection, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + flags: SecretSearchFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_collection_search_finish( + self_: *mut SecretCollection, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut glib::GList; + pub fn secret_collection_search_for_dbus_paths( + collection: *mut SecretCollection, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_collection_search_for_dbus_paths_finish( + collection: *mut SecretCollection, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut *mut c_char; + pub fn secret_collection_search_for_dbus_paths_sync( + collection: *mut SecretCollection, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut *mut c_char; + pub fn secret_collection_search_sync( + self_: *mut SecretCollection, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + flags: SecretSearchFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut glib::GList; + pub fn secret_collection_set_label( + self_: *mut SecretCollection, + label: *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_collection_set_label_finish( + self_: *mut SecretCollection, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_collection_set_label_sync( + self_: *mut SecretCollection, + label: *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + + //========================================================================= + // SecretItem + //========================================================================= + pub fn secret_item_get_type() -> GType; + pub fn secret_item_new_for_dbus_path_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretItem; + pub fn secret_item_new_for_dbus_path_sync( + service: *mut SecretService, + item_path: *const c_char, + flags: SecretItemFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretItem; + pub fn secret_item_create( + collection: *mut SecretCollection, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + label: *const c_char, + value: *mut SecretValue, + flags: SecretItemCreateFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_item_create_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretItem; + pub fn secret_item_create_sync( + collection: *mut SecretCollection, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + label: *const c_char, + value: *mut SecretValue, + flags: SecretItemCreateFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretItem; + pub fn secret_item_load_secrets( + items: *mut glib::GList, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_item_load_secrets_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_load_secrets_sync( + items: *mut glib::GList, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_new_for_dbus_path( + service: *mut SecretService, + item_path: *const c_char, + flags: SecretItemFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_item_delete( + self_: *mut SecretItem, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_item_delete_finish( + self_: *mut SecretItem, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_delete_sync( + self_: *mut SecretItem, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_get_attributes(self_: *mut SecretItem) -> *mut glib::GHashTable; + pub fn secret_item_get_created(self_: *mut SecretItem) -> u64; + pub fn secret_item_get_flags(self_: *mut SecretItem) -> SecretItemFlags; + pub fn secret_item_get_label(self_: *mut SecretItem) -> *mut c_char; + pub fn secret_item_get_locked(self_: *mut SecretItem) -> gboolean; + pub fn secret_item_get_modified(self_: *mut SecretItem) -> u64; + pub fn secret_item_get_schema_name(self_: *mut SecretItem) -> *mut c_char; + pub fn secret_item_get_secret(self_: *mut SecretItem) -> *mut SecretValue; + pub fn secret_item_get_service(self_: *mut SecretItem) -> *mut SecretService; + pub fn secret_item_load_secret( + self_: *mut SecretItem, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_item_load_secret_finish( + self_: *mut SecretItem, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_load_secret_sync( + self_: *mut SecretItem, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_refresh(self_: *mut SecretItem); + pub fn secret_item_set_attributes( + self_: *mut SecretItem, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_item_set_attributes_finish( + self_: *mut SecretItem, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_set_attributes_sync( + self_: *mut SecretItem, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_set_label( + self_: *mut SecretItem, + label: *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_item_set_label_finish( + self_: *mut SecretItem, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_set_label_sync( + self_: *mut SecretItem, + label: *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_set_secret( + self_: *mut SecretItem, + value: *mut SecretValue, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_item_set_secret_finish( + self_: *mut SecretItem, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_item_set_secret_sync( + self_: *mut SecretItem, + value: *mut SecretValue, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + + //========================================================================= + // SecretPrompt + //========================================================================= + pub fn secret_prompt_get_type() -> GType; + pub fn secret_prompt_perform( + self_: *mut SecretPrompt, + window_id: *const c_char, + return_type: *const glib::GVariantType, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_prompt_perform_finish( + self_: *mut SecretPrompt, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut glib::GVariant; + pub fn secret_prompt_perform_sync( + self_: *mut SecretPrompt, + window_id: *const c_char, + cancellable: *mut gio::GCancellable, + return_type: *const glib::GVariantType, + error: *mut *mut glib::GError, + ) -> *mut glib::GVariant; + pub fn secret_prompt_run( + self_: *mut SecretPrompt, + window_id: *const c_char, + cancellable: *mut gio::GCancellable, + return_type: *const glib::GVariantType, + error: *mut *mut glib::GError, + ) -> *mut glib::GVariant; + + //========================================================================= + // SecretService + //========================================================================= + pub fn secret_service_get_type() -> GType; + pub fn secret_service_disconnect(); + pub fn secret_service_get( + flags: SecretServiceFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_get_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretService; + pub fn secret_service_get_sync( + flags: SecretServiceFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretService; + pub fn secret_service_open( + service_gtype: GType, + service_bus_name: *const c_char, + flags: SecretServiceFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_open_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretService; + pub fn secret_service_open_sync( + service_gtype: GType, + service_bus_name: *const c_char, + flags: SecretServiceFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretService; + pub fn secret_service_clear( + service: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_clear_finish( + service: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_clear_sync( + service: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_create_collection_dbus_path( + self_: *mut SecretService, + properties: *mut glib::GHashTable, + alias: *const c_char, + flags: SecretCollectionCreateFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_create_collection_dbus_path_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_service_create_collection_dbus_path_sync( + self_: *mut SecretService, + properties: *mut glib::GHashTable, + alias: *const c_char, + flags: SecretCollectionCreateFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_service_create_item_dbus_path( + self_: *mut SecretService, + collection_path: *const c_char, + properties: *mut glib::GHashTable, + value: *mut SecretValue, + flags: SecretItemCreateFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_create_item_dbus_path_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_service_create_item_dbus_path_sync( + self_: *mut SecretService, + collection_path: *const c_char, + properties: *mut glib::GHashTable, + value: *mut SecretValue, + flags: SecretItemCreateFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_service_decode_dbus_secret( + service: *mut SecretService, + value: *mut glib::GVariant, + ) -> *mut SecretValue; + pub fn secret_service_delete_item_dbus_path( + self_: *mut SecretService, + item_path: *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_delete_item_dbus_path_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_delete_item_dbus_path_sync( + self_: *mut SecretService, + item_path: *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_encode_dbus_secret( + service: *mut SecretService, + value: *mut SecretValue, + ) -> *mut glib::GVariant; + pub fn secret_service_ensure_session( + self_: *mut SecretService, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_ensure_session_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_ensure_session_sync( + self_: *mut SecretService, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_get_collection_gtype(self_: *mut SecretService) -> GType; + pub fn secret_service_get_collections(self_: *mut SecretService) -> *mut glib::GList; + pub fn secret_service_get_flags(self_: *mut SecretService) -> SecretServiceFlags; + pub fn secret_service_get_item_gtype(self_: *mut SecretService) -> GType; + pub fn secret_service_get_secret_for_dbus_path( + self_: *mut SecretService, + item_path: *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_get_secret_for_dbus_path_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretValue; + pub fn secret_service_get_secret_for_dbus_path_sync( + self_: *mut SecretService, + item_path: *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretValue; + pub fn secret_service_get_secrets_for_dbus_paths( + self_: *mut SecretService, + item_paths: *mut *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_get_secrets_for_dbus_paths_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut glib::GHashTable; + pub fn secret_service_get_secrets_for_dbus_paths_sync( + self_: *mut SecretService, + item_paths: *mut *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut glib::GHashTable; + pub fn secret_service_get_session_algorithms(self_: *mut SecretService) -> *const c_char; + pub fn secret_service_get_session_dbus_path(self_: *mut SecretService) -> *const c_char; + pub fn secret_service_load_collections( + self_: *mut SecretService, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_load_collections_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_load_collections_sync( + self_: *mut SecretService, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_lock( + service: *mut SecretService, + objects: *mut glib::GList, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_lock_dbus_paths( + self_: *mut SecretService, + paths: *mut *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_lock_dbus_paths_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + locked: *mut *mut *mut c_char, + error: *mut *mut glib::GError, + ) -> c_int; + pub fn secret_service_lock_dbus_paths_sync( + self_: *mut SecretService, + paths: *mut *const c_char, + cancellable: *mut gio::GCancellable, + locked: *mut *mut *mut c_char, + error: *mut *mut glib::GError, + ) -> c_int; + pub fn secret_service_lock_finish( + service: *mut SecretService, + result: *mut gio::GAsyncResult, + locked: *mut *mut glib::GList, + error: *mut *mut glib::GError, + ) -> c_int; + pub fn secret_service_lock_sync( + service: *mut SecretService, + objects: *mut glib::GList, + cancellable: *mut gio::GCancellable, + locked: *mut *mut glib::GList, + error: *mut *mut glib::GError, + ) -> c_int; + pub fn secret_service_lookup( + service: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_lookup_finish( + service: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretValue; + pub fn secret_service_lookup_sync( + service: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretValue; + pub fn secret_service_prompt( + self_: *mut SecretService, + prompt: *mut SecretPrompt, + return_type: *const glib::GVariantType, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_prompt_at_dbus_path( + self_: *mut SecretService, + prompt_path: *const c_char, + return_type: *const glib::GVariantType, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_prompt_at_dbus_path_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut glib::GVariant; + pub fn secret_service_prompt_at_dbus_path_sync( + self_: *mut SecretService, + prompt_path: *const c_char, + cancellable: *mut gio::GCancellable, + return_type: *const glib::GVariantType, + error: *mut *mut glib::GError, + ) -> *mut glib::GVariant; + pub fn secret_service_prompt_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut glib::GVariant; + pub fn secret_service_prompt_sync( + self_: *mut SecretService, + prompt: *mut SecretPrompt, + cancellable: *mut gio::GCancellable, + return_type: *const glib::GVariantType, + error: *mut *mut glib::GError, + ) -> *mut glib::GVariant; + pub fn secret_service_read_alias_dbus_path( + self_: *mut SecretService, + alias: *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_read_alias_dbus_path_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_service_read_alias_dbus_path_sync( + self_: *mut SecretService, + alias: *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_service_search( + service: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + flags: SecretSearchFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_search_finish( + service: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut glib::GList; + pub fn secret_service_search_for_dbus_paths( + self_: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_search_for_dbus_paths_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + unlocked: *mut *mut *mut c_char, + locked: *mut *mut *mut c_char, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_search_for_dbus_paths_sync( + self_: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + unlocked: *mut *mut *mut c_char, + locked: *mut *mut *mut c_char, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_search_sync( + service: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + flags: SecretSearchFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut glib::GList; + pub fn secret_service_set_alias( + service: *mut SecretService, + alias: *const c_char, + collection: *mut SecretCollection, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_set_alias_finish( + service: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_set_alias_sync( + service: *mut SecretService, + alias: *const c_char, + collection: *mut SecretCollection, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_set_alias_to_dbus_path( + self_: *mut SecretService, + alias: *const c_char, + collection_path: *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_set_alias_to_dbus_path_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_set_alias_to_dbus_path_sync( + self_: *mut SecretService, + alias: *const c_char, + collection_path: *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_store( + service: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + collection: *const c_char, + label: *const c_char, + value: *mut SecretValue, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_store_finish( + service: *mut SecretService, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_store_sync( + service: *mut SecretService, + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + collection: *const c_char, + label: *const c_char, + value: *mut SecretValue, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_service_unlock( + service: *mut SecretService, + objects: *mut glib::GList, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_unlock_dbus_paths( + self_: *mut SecretService, + paths: *mut *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_service_unlock_dbus_paths_finish( + self_: *mut SecretService, + result: *mut gio::GAsyncResult, + unlocked: *mut *mut *mut c_char, + error: *mut *mut glib::GError, + ) -> c_int; + pub fn secret_service_unlock_dbus_paths_sync( + self_: *mut SecretService, + paths: *mut *const c_char, + cancellable: *mut gio::GCancellable, + unlocked: *mut *mut *mut c_char, + error: *mut *mut glib::GError, + ) -> c_int; + pub fn secret_service_unlock_finish( + service: *mut SecretService, + result: *mut gio::GAsyncResult, + unlocked: *mut *mut glib::GList, + error: *mut *mut glib::GError, + ) -> c_int; + pub fn secret_service_unlock_sync( + service: *mut SecretService, + objects: *mut glib::GList, + cancellable: *mut gio::GCancellable, + unlocked: *mut *mut glib::GList, + error: *mut *mut glib::GError, + ) -> c_int; + + //========================================================================= + // SecretBackend + //========================================================================= + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_backend_get_type() -> GType; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_backend_get( + flags: SecretBackendFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_backend_get_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretBackend; + + //========================================================================= + // SecretRetrievable + //========================================================================= + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_retrievable_get_type() -> GType; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_retrievable_get_attributes( + self_: *mut SecretRetrievable, + ) -> *mut glib::GHashTable; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_retrievable_get_created(self_: *mut SecretRetrievable) -> u64; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_retrievable_get_label(self_: *mut SecretRetrievable) -> *mut c_char; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_retrievable_get_modified(self_: *mut SecretRetrievable) -> u64; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_retrievable_retrieve_secret( + self_: *mut SecretRetrievable, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_retrievable_retrieve_secret_finish( + self_: *mut SecretRetrievable, + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretValue; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_retrievable_retrieve_secret_sync( + self_: *mut SecretRetrievable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretValue; + + //========================================================================= + // Other functions + //========================================================================= + pub fn secret_attributes_build(schema: *const SecretSchema, ...) -> *mut glib::GHashTable; + //pub fn secret_attributes_buildv(schema: *const SecretSchema, va: /*Unimplemented*/va_list) -> *mut glib::GHashTable; + #[cfg(feature = "v0_21_2")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] + pub fn secret_attributes_validate( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v0_18_6")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] + pub fn secret_get_schema(type_: SecretSchemaType) -> *const SecretSchema; + pub fn secret_password_clear( + schema: *const SecretSchema, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ... + ); + pub fn secret_password_clear_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_password_clear_sync( + schema: *const SecretSchema, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ... + ) -> gboolean; + pub fn secret_password_clearv( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + pub fn secret_password_clearv_sync( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_password_free(password: *mut c_char); + pub fn secret_password_lookup( + schema: *const SecretSchema, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ... + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_lookup_binary_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut SecretValue; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_lookup_binary_sync( + schema: *const SecretSchema, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ... + ) -> *mut SecretValue; + pub fn secret_password_lookup_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_password_lookup_nonpageable_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_password_lookup_nonpageable_sync( + schema: *const SecretSchema, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ... + ) -> *mut c_char; + pub fn secret_password_lookup_sync( + schema: *const SecretSchema, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ... + ) -> *mut c_char; + pub fn secret_password_lookupv( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_lookupv_binary_sync( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut SecretValue; + pub fn secret_password_lookupv_nonpageable_sync( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut c_char; + pub fn secret_password_lookupv_sync( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut c_char; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_search( + schema: *const SecretSchema, + flags: SecretSearchFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ... + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_search_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> *mut glib::GList; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_search_sync( + schema: *const SecretSchema, + flags: SecretSearchFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ... + ) -> *mut glib::GList; + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_searchv( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + flags: SecretSearchFlags, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_searchv_sync( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + flags: SecretSearchFlags, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> *mut glib::GList; + pub fn secret_password_store( + schema: *const SecretSchema, + collection: *const c_char, + label: *const c_char, + password: *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ... + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_store_binary( + schema: *const SecretSchema, + collection: *const c_char, + label: *const c_char, + value: *mut SecretValue, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ... + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_store_binary_sync( + schema: *const SecretSchema, + collection: *const c_char, + label: *const c_char, + value: *mut SecretValue, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ... + ) -> gboolean; + pub fn secret_password_store_finish( + result: *mut gio::GAsyncResult, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_password_store_sync( + schema: *const SecretSchema, + collection: *const c_char, + label: *const c_char, + password: *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ... + ) -> gboolean; + pub fn secret_password_storev( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + collection: *const c_char, + label: *const c_char, + password: *const c_char, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_storev_binary( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + collection: *const c_char, + label: *const c_char, + value: *mut SecretValue, + cancellable: *mut gio::GCancellable, + callback: gio::GAsyncReadyCallback, + user_data: gpointer, + ); + #[cfg(feature = "v0_19")] + #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] + pub fn secret_password_storev_binary_sync( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + collection: *const c_char, + label: *const c_char, + value: *mut SecretValue, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_password_storev_sync( + schema: *const SecretSchema, + attributes: *mut glib::GHashTable, + collection: *const c_char, + label: *const c_char, + password: *const c_char, + cancellable: *mut gio::GCancellable, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn secret_password_wipe(password: *mut c_char); + +} diff --git a/libsecret/sys/tests/abi.rs b/libsecret/sys/tests/abi.rs new file mode 100644 index 0000000..591466e --- /dev/null +++ b/libsecret/sys/tests/abi.rs @@ -0,0 +1,405 @@ +// Generated by gir (https://github.com/gtk-rs/gir @ 4dd714f7f3b1) +// from +// from gir-files (https://github.com/gtk-rs/gir-files.git @ b9db716f1bb7) +// DO NOT EDIT + +#![cfg(unix)] + +use libsecret_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["libsecret-1"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec<String>, +} + +impl Compiler { + pub fn new() -> Result<Self, Box<dyn Error>> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box<dyn Error>> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result<Vec<String>, Box<dyn Error>> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result<Vec<String>, Box<dyn Error>> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result<String, Box<dyn Error>> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "SecretBackendFlags", + Layout { + size: size_of::<SecretBackendFlags>(), + alignment: align_of::<SecretBackendFlags>(), + }, + ), + ( + "SecretBackendInterface", + Layout { + size: size_of::<SecretBackendInterface>(), + alignment: align_of::<SecretBackendInterface>(), + }, + ), + ( + "SecretCollection", + Layout { + size: size_of::<SecretCollection>(), + alignment: align_of::<SecretCollection>(), + }, + ), + ( + "SecretCollectionClass", + Layout { + size: size_of::<SecretCollectionClass>(), + alignment: align_of::<SecretCollectionClass>(), + }, + ), + ( + "SecretCollectionCreateFlags", + Layout { + size: size_of::<SecretCollectionCreateFlags>(), + alignment: align_of::<SecretCollectionCreateFlags>(), + }, + ), + ( + "SecretCollectionFlags", + Layout { + size: size_of::<SecretCollectionFlags>(), + alignment: align_of::<SecretCollectionFlags>(), + }, + ), + ( + "SecretError", + Layout { + size: size_of::<SecretError>(), + alignment: align_of::<SecretError>(), + }, + ), + ( + "SecretItem", + Layout { + size: size_of::<SecretItem>(), + alignment: align_of::<SecretItem>(), + }, + ), + ( + "SecretItemClass", + Layout { + size: size_of::<SecretItemClass>(), + alignment: align_of::<SecretItemClass>(), + }, + ), + ( + "SecretItemCreateFlags", + Layout { + size: size_of::<SecretItemCreateFlags>(), + alignment: align_of::<SecretItemCreateFlags>(), + }, + ), + ( + "SecretItemFlags", + Layout { + size: size_of::<SecretItemFlags>(), + alignment: align_of::<SecretItemFlags>(), + }, + ), + ( + "SecretPrompt", + Layout { + size: size_of::<SecretPrompt>(), + alignment: align_of::<SecretPrompt>(), + }, + ), + ( + "SecretPromptClass", + Layout { + size: size_of::<SecretPromptClass>(), + alignment: align_of::<SecretPromptClass>(), + }, + ), + ( + "SecretRetrievableInterface", + Layout { + size: size_of::<SecretRetrievableInterface>(), + alignment: align_of::<SecretRetrievableInterface>(), + }, + ), + ( + "SecretSchema", + Layout { + size: size_of::<SecretSchema>(), + alignment: align_of::<SecretSchema>(), + }, + ), + ( + "SecretSchemaAttribute", + Layout { + size: size_of::<SecretSchemaAttribute>(), + alignment: align_of::<SecretSchemaAttribute>(), + }, + ), + ( + "SecretSchemaAttributeType", + Layout { + size: size_of::<SecretSchemaAttributeType>(), + alignment: align_of::<SecretSchemaAttributeType>(), + }, + ), + ( + "SecretSchemaFlags", + Layout { + size: size_of::<SecretSchemaFlags>(), + alignment: align_of::<SecretSchemaFlags>(), + }, + ), + ( + "SecretSchemaType", + Layout { + size: size_of::<SecretSchemaType>(), + alignment: align_of::<SecretSchemaType>(), + }, + ), + ( + "SecretSearchFlags", + Layout { + size: size_of::<SecretSearchFlags>(), + alignment: align_of::<SecretSearchFlags>(), + }, + ), + ( + "SecretService", + Layout { + size: size_of::<SecretService>(), + alignment: align_of::<SecretService>(), + }, + ), + ( + "SecretServiceClass", + Layout { + size: size_of::<SecretServiceClass>(), + alignment: align_of::<SecretServiceClass>(), + }, + ), + ( + "SecretServiceFlags", + Layout { + size: size_of::<SecretServiceFlags>(), + alignment: align_of::<SecretServiceFlags>(), + }, + ), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("SECRET_BACKEND_EXTENSION_POINT_NAME", "secret-backend"), + ("(gint) SECRET_BACKEND_LOAD_COLLECTIONS", "4"), + ("(gint) SECRET_BACKEND_NONE", "0"), + ("(gint) SECRET_BACKEND_OPEN_SESSION", "2"), + ("(guint) SECRET_COLLECTION_CREATE_NONE", "0"), + ("SECRET_COLLECTION_DEFAULT", "default"), + ("(guint) SECRET_COLLECTION_LOAD_ITEMS", "2"), + ("(guint) SECRET_COLLECTION_NONE", "0"), + ("SECRET_COLLECTION_SESSION", "session"), + ("(gint) SECRET_ERROR_ALREADY_EXISTS", "4"), + ("(gint) SECRET_ERROR_EMPTY_TABLE", "9"), + ("(gint) SECRET_ERROR_INVALID_FILE_FORMAT", "5"), + ("(gint) SECRET_ERROR_IS_LOCKED", "2"), + ("(gint) SECRET_ERROR_MISMATCHED_SCHEMA", "6"), + ("(gint) SECRET_ERROR_NO_MATCHING_ATTRIBUTE", "7"), + ("(gint) SECRET_ERROR_NO_SUCH_OBJECT", "3"), + ("(gint) SECRET_ERROR_PROTOCOL", "1"), + ("(gint) SECRET_ERROR_WRONG_TYPE", "8"), + ("(guint) SECRET_ITEM_CREATE_NONE", "0"), + ("(guint) SECRET_ITEM_CREATE_REPLACE", "2"), + ("(guint) SECRET_ITEM_LOAD_SECRET", "2"), + ("(guint) SECRET_ITEM_NONE", "0"), + ("(gint) SECRET_SCHEMA_ATTRIBUTE_BOOLEAN", "2"), + ("(gint) SECRET_SCHEMA_ATTRIBUTE_INTEGER", "1"), + ("(gint) SECRET_SCHEMA_ATTRIBUTE_STRING", "0"), + ("(guint) SECRET_SCHEMA_DONT_MATCH_NAME", "2"), + ("(guint) SECRET_SCHEMA_NONE", "0"), + ("(gint) SECRET_SCHEMA_TYPE_COMPAT_NETWORK", "1"), + ("(gint) SECRET_SCHEMA_TYPE_NOTE", "0"), + ("(guint) SECRET_SEARCH_ALL", "2"), + ("(guint) SECRET_SEARCH_LOAD_SECRETS", "8"), + ("(guint) SECRET_SEARCH_NONE", "0"), + ("(guint) SECRET_SEARCH_UNLOCK", "4"), + ("(guint) SECRET_SERVICE_LOAD_COLLECTIONS", "4"), + ("(guint) SECRET_SERVICE_NONE", "0"), + ("(guint) SECRET_SERVICE_OPEN_SESSION", "2"), +]; diff --git a/libsecret/sys/tests/constant.c b/libsecret/sys/tests/constant.c new file mode 100644 index 0000000..ff0f600 --- /dev/null +++ b/libsecret/sys/tests/constant.c @@ -0,0 +1,69 @@ +// Generated by gir (https://github.com/gtk-rs/gir @ 4dd714f7f3b1) +// from +// from gir-files (https://github.com/gtk-rs/gir-files.git @ b9db716f1bb7) +// DO NOT EDIT + +#include "manual.h" +#include <stdio.h> + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((CONSTANT_NAME), \ + char *: "%s", \ + const char *: "%s", \ + char: "%c", \ + signed char: "%hhd", \ + unsigned char: "%hhu", \ + short int: "%hd", \ + unsigned short int: "%hu", \ + int: "%d", \ + unsigned int: "%u", \ + long: "%ld", \ + unsigned long: "%lu", \ + long long: "%lld", \ + unsigned long long: "%llu", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + PRINT_CONSTANT(SECRET_BACKEND_EXTENSION_POINT_NAME); + PRINT_CONSTANT((gint) SECRET_BACKEND_LOAD_COLLECTIONS); + PRINT_CONSTANT((gint) SECRET_BACKEND_NONE); + PRINT_CONSTANT((gint) SECRET_BACKEND_OPEN_SESSION); + PRINT_CONSTANT((guint) SECRET_COLLECTION_CREATE_NONE); + PRINT_CONSTANT(SECRET_COLLECTION_DEFAULT); + PRINT_CONSTANT((guint) SECRET_COLLECTION_LOAD_ITEMS); + PRINT_CONSTANT((guint) SECRET_COLLECTION_NONE); + PRINT_CONSTANT(SECRET_COLLECTION_SESSION); + PRINT_CONSTANT((gint) SECRET_ERROR_ALREADY_EXISTS); + PRINT_CONSTANT((gint) SECRET_ERROR_EMPTY_TABLE); + PRINT_CONSTANT((gint) SECRET_ERROR_INVALID_FILE_FORMAT); + PRINT_CONSTANT((gint) SECRET_ERROR_IS_LOCKED); + PRINT_CONSTANT((gint) SECRET_ERROR_MISMATCHED_SCHEMA); + PRINT_CONSTANT((gint) SECRET_ERROR_NO_MATCHING_ATTRIBUTE); + PRINT_CONSTANT((gint) SECRET_ERROR_NO_SUCH_OBJECT); + PRINT_CONSTANT((gint) SECRET_ERROR_PROTOCOL); + PRINT_CONSTANT((gint) SECRET_ERROR_WRONG_TYPE); + PRINT_CONSTANT((guint) SECRET_ITEM_CREATE_NONE); + PRINT_CONSTANT((guint) SECRET_ITEM_CREATE_REPLACE); + PRINT_CONSTANT((guint) SECRET_ITEM_LOAD_SECRET); + PRINT_CONSTANT((guint) SECRET_ITEM_NONE); + PRINT_CONSTANT((gint) SECRET_SCHEMA_ATTRIBUTE_BOOLEAN); + PRINT_CONSTANT((gint) SECRET_SCHEMA_ATTRIBUTE_INTEGER); + PRINT_CONSTANT((gint) SECRET_SCHEMA_ATTRIBUTE_STRING); + PRINT_CONSTANT((guint) SECRET_SCHEMA_DONT_MATCH_NAME); + PRINT_CONSTANT((guint) SECRET_SCHEMA_NONE); + PRINT_CONSTANT((gint) SECRET_SCHEMA_TYPE_COMPAT_NETWORK); + PRINT_CONSTANT((gint) SECRET_SCHEMA_TYPE_NOTE); + PRINT_CONSTANT((guint) SECRET_SEARCH_ALL); + PRINT_CONSTANT((guint) SECRET_SEARCH_LOAD_SECRETS); + PRINT_CONSTANT((guint) SECRET_SEARCH_NONE); + PRINT_CONSTANT((guint) SECRET_SEARCH_UNLOCK); + PRINT_CONSTANT((guint) SECRET_SERVICE_LOAD_COLLECTIONS); + PRINT_CONSTANT((guint) SECRET_SERVICE_NONE); + PRINT_CONSTANT((guint) SECRET_SERVICE_OPEN_SESSION); + return 0; +} diff --git a/libsecret/sys/tests/layout.c b/libsecret/sys/tests/layout.c new file mode 100644 index 0000000..37a6016 --- /dev/null +++ b/libsecret/sys/tests/layout.c @@ -0,0 +1,35 @@ +// Generated by gir (https://github.com/gtk-rs/gir @ 4dd714f7f3b1) +// from +// from gir-files (https://github.com/gtk-rs/gir-files.git @ b9db716f1bb7) +// DO NOT EDIT + +#include "manual.h" +#include <stdalign.h> +#include <stdio.h> + +int main() { + printf("%s;%zu;%zu\n", "SecretBackendFlags", sizeof(SecretBackendFlags), alignof(SecretBackendFlags)); + printf("%s;%zu;%zu\n", "SecretBackendInterface", sizeof(SecretBackendInterface), alignof(SecretBackendInterface)); + printf("%s;%zu;%zu\n", "SecretCollection", sizeof(SecretCollection), alignof(SecretCollection)); + printf("%s;%zu;%zu\n", "SecretCollectionClass", sizeof(SecretCollectionClass), alignof(SecretCollectionClass)); + printf("%s;%zu;%zu\n", "SecretCollectionCreateFlags", sizeof(SecretCollectionCreateFlags), alignof(SecretCollectionCreateFlags)); + printf("%s;%zu;%zu\n", "SecretCollectionFlags", sizeof(SecretCollectionFlags), alignof(SecretCollectionFlags)); + printf("%s;%zu;%zu\n", "SecretError", sizeof(SecretError), alignof(SecretError)); + printf("%s;%zu;%zu\n", "SecretItem", sizeof(SecretItem), alignof(SecretItem)); + printf("%s;%zu;%zu\n", "SecretItemClass", sizeof(SecretItemClass), alignof(SecretItemClass)); + printf("%s;%zu;%zu\n", "SecretItemCreateFlags", sizeof(SecretItemCreateFlags), alignof(SecretItemCreateFlags)); + printf("%s;%zu;%zu\n", "SecretItemFlags", sizeof(SecretItemFlags), alignof(SecretItemFlags)); + printf("%s;%zu;%zu\n", "SecretPrompt", sizeof(SecretPrompt), alignof(SecretPrompt)); + printf("%s;%zu;%zu\n", "SecretPromptClass", sizeof(SecretPromptClass), alignof(SecretPromptClass)); + printf("%s;%zu;%zu\n", "SecretRetrievableInterface", sizeof(SecretRetrievableInterface), alignof(SecretRetrievableInterface)); + printf("%s;%zu;%zu\n", "SecretSchema", sizeof(SecretSchema), alignof(SecretSchema)); + printf("%s;%zu;%zu\n", "SecretSchemaAttribute", sizeof(SecretSchemaAttribute), alignof(SecretSchemaAttribute)); + printf("%s;%zu;%zu\n", "SecretSchemaAttributeType", sizeof(SecretSchemaAttributeType), alignof(SecretSchemaAttributeType)); + printf("%s;%zu;%zu\n", "SecretSchemaFlags", sizeof(SecretSchemaFlags), alignof(SecretSchemaFlags)); + printf("%s;%zu;%zu\n", "SecretSchemaType", sizeof(SecretSchemaType), alignof(SecretSchemaType)); + printf("%s;%zu;%zu\n", "SecretSearchFlags", sizeof(SecretSearchFlags), alignof(SecretSearchFlags)); + printf("%s;%zu;%zu\n", "SecretService", sizeof(SecretService), alignof(SecretService)); + printf("%s;%zu;%zu\n", "SecretServiceClass", sizeof(SecretServiceClass), alignof(SecretServiceClass)); + printf("%s;%zu;%zu\n", "SecretServiceFlags", sizeof(SecretServiceFlags), alignof(SecretServiceFlags)); + return 0; +} diff --git a/libsecret/sys/tests/manual.h b/libsecret/sys/tests/manual.h new file mode 100644 index 0000000..2633804 --- /dev/null +++ b/libsecret/sys/tests/manual.h @@ -0,0 +1,3 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +#include <libsecret/secret.h> |