diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-05-07 16:35:20 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-05-07 18:24:24 +0200 |
commit | c0308304ad20cd702231572eba3dedb293bdc103 (patch) | |
tree | 0b1344e7adf4004c61008b3fe485b42b765db3c6 /ffi | |
parent | 83a109af5039cb764aa9b7ffddc14bafd3d42dca (diff) |
openpgp-ffi, ffi: Fix calling convention on Windows.
- Use `extern "C"` instead of `extern "system"`. The latter selects
stdcall, which is only appropriate for talking to the Windows API.
Diffstat (limited to 'ffi')
-rw-r--r-- | ffi/src/core.rs | 77 | ||||
-rw-r--r-- | ffi/src/net.rs | 44 | ||||
-rw-r--r-- | ffi/src/store.rs | 253 | ||||
-rw-r--r-- | ffi/tests/c-tests.rs | 2 |
4 files changed, 178 insertions, 198 deletions
diff --git a/ffi/src/core.rs b/ffi/src/core.rs index 8ad3a655..5b139fb4 100644 --- a/ffi/src/core.rs +++ b/ffi/src/core.rs @@ -64,9 +64,8 @@ impl Context { /// Returns the last error. /// /// Returns and removes the last error from the context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_last_error(ctx: *mut Context) - -> *mut ::error::Error { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_last_error(ctx: *mut Context) -> *mut ::error::Error { let ctx = ffi_param_ref_mut!(ctx); ::std::mem::replace(&mut ctx.e, ptr::null_mut()) } @@ -79,10 +78,10 @@ pub extern "system" fn sq_context_last_error(ctx: *mut Context) /// /// Returns `NULL` on errors. If `errp` is not `NULL`, the error is /// stored there. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_new(domain: *const c_char, - errp: Option<&mut *mut ::error::Error>) - -> *mut Context { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_new(domain: *const c_char, + errp: Option<&mut *mut ::error::Error>) + -> *mut Context { ffi_make_fry_from_errp!(errp); let domain = ffi_param_cstr!(domain).to_string_lossy(); @@ -90,8 +89,8 @@ pub extern "system" fn sq_context_new(domain: *const c_char, } /// Frees a context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_free(context: Option<&mut Context>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_free(context: Option<&mut Context>) { ffi_free!(context) } @@ -104,52 +103,51 @@ pub extern "system" fn sq_context_free(context: Option<&mut Context>) { /// The configuration is seeded like in `sq_context_new`, but can be /// modified. A configuration has to be finalized using /// `sq_config_build()` in order to turn it into a Context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_configure(domain: *const c_char) - -> *mut Config { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_configure(domain: *const c_char) -> *mut Config { let domain = ffi_param_cstr!(domain).to_string_lossy(); Box::into_raw(Box::new(core::Context::configure(&domain))) } /// Returns the domain of the context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_domain(ctx: *const Context) -> *const c_char { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_domain(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.domain().as_bytes().as_ptr() as *const c_char } /// Returns the directory containing shared state. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_home(ctx: *const Context) -> *const c_char { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_home(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.home().to_string_lossy().as_ptr() as *const c_char } /// Returns the directory containing backend servers. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_lib(ctx: *const Context) -> *const c_char { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_lib(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.lib().to_string_lossy().as_bytes().as_ptr() as *const c_char } /// Returns the network policy. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_network_policy(ctx: *const Context) -> c_int { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_network_policy(ctx: *const Context) -> c_int { let ctx = ffi_param_ref!(ctx); u8::from(ctx.c.network_policy()) as c_int } /// Returns the IPC policy. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_ipc_policy(ctx: *const Context) -> c_int { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_ipc_policy(ctx: *const Context) -> c_int { let ctx = ffi_param_ref!(ctx); u8::from(ctx.c.ipc_policy()) as c_int } /// Returns whether or not this is an ephemeral context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_ephemeral(ctx: *const Context) -> uint8_t { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_ephemeral(ctx: *const Context) -> uint8_t { let ctx = ffi_param_ref!(ctx); if ctx.c.ephemeral() { 1 } else { 0 } } @@ -161,10 +159,9 @@ pub extern "system" fn sq_context_ephemeral(ctx: *const Context) -> uint8_t { /// /// Consumes `cfg`. Returns `NULL` on errors. Returns `NULL` on /// errors. If `errp` is not `NULL`, the error is stored there. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_build(cfg: *mut Config, - errp: Option<&mut *mut ::error::Error>) - -> *mut Context { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_build(cfg: *mut Config, errp: Option<&mut *mut ::error::Error>) + -> *mut Context { ffi_make_fry_from_errp!(errp); let cfg = ffi_param_move!(cfg); @@ -172,27 +169,24 @@ pub extern "system" fn sq_config_build(cfg: *mut Config, } /// Sets the directory containing shared state. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_home(cfg: *mut Config, - home: *const c_char) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_home(cfg: *mut Config, home: *const c_char) { let cfg = ffi_param_ref_mut!(cfg); let home = ffi_param_cstr!(home).to_string_lossy(); cfg.set_home(home.as_ref()); } /// Set the directory containing backend servers. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_lib(cfg: *mut Config, - lib: *const c_char) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_lib(cfg: *mut Config, lib: *const c_char) { let cfg = ffi_param_ref_mut!(cfg); let lib = ffi_param_cstr!(lib).to_string_lossy(); cfg.set_lib(&lib.as_ref()); } /// Sets the network policy. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_network_policy(cfg: *mut Config, - policy: c_int) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_network_policy(cfg: *mut Config, policy: c_int) { let cfg = ffi_param_ref_mut!(cfg); if policy < 0 || policy > 3 { panic!("Bad network policy: {}", policy); @@ -201,9 +195,8 @@ pub extern "system" fn sq_config_network_policy(cfg: *mut Config, } /// Sets the IPC policy. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_ipc_policy(cfg: *mut Config, - policy: c_int) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_ipc_policy(cfg: *mut Config, policy: c_int) { let cfg = ffi_param_ref_mut!(cfg); if policy < 0 || policy > 2 { panic!("Bad ipc policy: {}", policy); @@ -212,8 +205,8 @@ pub extern "system" fn sq_config_ipc_policy(cfg: *mut Config, } /// Makes this context ephemeral. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_ephemeral(cfg: *mut Config) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_ephemeral(cfg: *mut Config) { let cfg = ffi_param_ref_mut!(cfg); cfg.set_ephemeral(); } diff --git a/ffi/src/net.rs b/ffi/src/net.rs index 1a2712b4..06942739 100644 --- a/ffi/src/net.rs +++ b/ffi/src/net.rs @@ -50,9 +50,8 @@ use Maybe; /// e.g. `hkps://examle.org`. /// /// Returns `NULL` on errors. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_keyserver_new(ctx: *mut Context, - uri: *const c_char) -> *mut KeyServer { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_keyserver_new(ctx: *mut Context, uri: *const c_char) -> *mut KeyServer { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let uri = ffi_param_cstr!(uri).to_string_lossy(); @@ -67,11 +66,11 @@ pub extern "system" fn sq_keyserver_new(ctx: *mut Context, /// size `len` used to authenticate the server. /// /// Returns `NULL` on errors. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_keyserver_with_cert(ctx: *mut Context, - uri: *const c_char, - cert: *const uint8_t, - len: size_t) -> *mut KeyServer { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_keyserver_with_cert(ctx: *mut Context, + uri: *const c_char, + cert: *const uint8_t, + len: size_t) -> *mut KeyServer { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let uri = ffi_param_cstr!(uri).to_string_lossy(); @@ -96,28 +95,27 @@ pub extern "system" fn sq_keyserver_with_cert(ctx: *mut Context, /// included in this library. It is a good default choice. /// /// Returns `NULL` on errors. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_keyserver_sks_pool(ctx: *mut Context) - -> *mut KeyServer { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_keyserver_sks_pool(ctx: *mut Context) -> *mut KeyServer { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); ffi_try_box!(KeyServer::sks_pool(&ctx.c)) } /// Frees a keyserver object. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_keyserver_free(ks: Option<&mut KeyServer>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_keyserver_free(ks: Option<&mut KeyServer>) { ffi_free!(ks) } /// Retrieves the key with the given `keyid`. /// /// Returns `NULL` on errors. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_keyserver_get(ctx: *mut Context, - ks: *mut KeyServer, - id: *const KeyID) - -> Maybe<TPK> { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_keyserver_get(ctx: *mut Context, + ks: *mut KeyServer, + id: *const KeyID) + -> Maybe<TPK> { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let ks = ffi_param_ref_mut!(ks); @@ -129,11 +127,11 @@ pub extern "system" fn sq_keyserver_get(ctx: *mut Context, /// Sends the given key to the server. /// /// Returns != 0 on errors. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_keyserver_send(ctx: *mut Context, - ks: *mut KeyServer, - tpk: *const TPK) - -> Status { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_keyserver_send(ctx: *mut Context, + ks: *mut KeyServer, + tpk: *const TPK) + -> Status { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let ks = ffi_param_ref_mut!(ks); diff --git a/ffi/src/store.rs b/ffi/src/store.rs index 3b4baa50..2a2c18cf 100644 --- a/ffi/src/store.rs +++ b/ffi/src/store.rs @@ -44,10 +44,10 @@ use MoveResultIntoRaw; use Maybe; /// Lists all stores with the given prefix. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_list_stores(ctx: *mut Context, - domain_prefix: *const c_char) - -> *mut StoreIter { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_list_stores(ctx: *mut Context, + domain_prefix: *const c_char) + -> *mut StoreIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let domain_prefix = ffi_param_cstr!(domain_prefix).to_string_lossy(); @@ -61,12 +61,12 @@ pub extern "system" fn sq_store_list_stores(ctx: *mut Context, /// stores domain is stored there. If `namep` is not `NULL`, the /// stores name is stored there. If `policyp` is not `NULL`, the /// stores network policy is stored there. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_iter_next(iter: *mut StoreIter, - domainp: Option<&mut *mut c_char>, - namep: Option<&mut *mut c_char>, - policyp: Option<&mut uint8_t>) - -> *mut Store { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_iter_next(iter: *mut StoreIter, + domainp: Option<&mut *mut c_char>, + namep: Option<&mut *mut c_char>, + policyp: Option<&mut uint8_t>) + -> *mut Store { let iter = ffi_param_ref_mut!(iter); match iter.next() { Some((domain, name, policy, store)) => { @@ -89,15 +89,14 @@ pub extern "system" fn sq_store_iter_next(iter: *mut StoreIter, } /// Frees a sq_store_iter_t. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_iter_free(iter: Option<&mut StoreIter>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_iter_free(iter: Option<&mut StoreIter>) { ffi_free!(iter) } /// Lists all keys in the common key pool. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_list_keys(ctx: *mut Context) - -> *mut KeyIter { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_list_keys(ctx: *mut Context) -> *mut KeyIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); @@ -105,9 +104,8 @@ pub extern "system" fn sq_store_list_keys(ctx: *mut Context) } /// Lists all log entries. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_server_log(ctx: *mut Context) - -> *mut LogIter { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_server_log(ctx: *mut Context) -> *mut LogIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); @@ -118,10 +116,10 @@ pub extern "system" fn sq_store_server_log(ctx: *mut Context) /// /// Returns `NULL` on exhaustion. If `fpp` is not `NULL`, the key's /// fingerprint is stored there. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_key_iter_next(iter: *mut KeyIter, - fpp: Option<&mut Maybe<Fingerprint>>) - -> *mut Key { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_key_iter_next(iter: *mut KeyIter, + fpp: Option<&mut Maybe<Fingerprint>>) + -> *mut Key { let iter = ffi_param_ref_mut!(iter); match iter.next() { Some((fingerprint, key)) => { @@ -141,8 +139,8 @@ pub extern "system" fn sq_key_iter_next(iter: *mut KeyIter, } /// Frees a sq_key_iter_t. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_key_iter_free(iter: Option<&mut KeyIter>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_key_iter_free(iter: Option<&mut KeyIter>) { ffi_free!(iter) } @@ -150,9 +148,8 @@ pub extern "system" fn sq_key_iter_free(iter: Option<&mut KeyIter>) { /// Returns the next log entry. /// /// Returns `NULL` on exhaustion. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_log_iter_next(iter: *mut LogIter) - -> *mut Log { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_log_iter_next(iter: *mut LogIter) -> *mut Log { let iter = ffi_param_ref_mut!(iter); match iter.next() { Some(e) => { @@ -176,8 +173,8 @@ pub extern "system" fn sq_log_iter_next(iter: *mut LogIter) } /// Frees a sq_log_iter_t. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_log_iter_free(iter: Option<&mut LogIter>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_log_iter_free(iter: Option<&mut LogIter>) { ffi_free!(iter) } @@ -192,10 +189,10 @@ pub extern "system" fn sq_log_iter_free(iter: Option<&mut LogIter>) { /// of the context that created the store in the first place. /// Opening the store with a different network policy is /// forbidden. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_open(ctx: *mut Context, - name: *const c_char) - -> *mut Store { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_open(ctx: *mut Context, + name: *const c_char) + -> *mut Store { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let name = ffi_param_cstr!(name).to_string_lossy(); @@ -204,18 +201,18 @@ pub extern "system" fn sq_store_open(ctx: *mut Context, } /// Frees a sq_store_t. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_free(store: Option<&mut Store>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_free(store: Option<&mut Store>) { ffi_free!(store) } /// Adds a key identified by fingerprint to the store. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_add(ctx: *mut Context, - store: *const Store, - label: *const c_char, - fingerprint: *const Fingerprint) - -> *mut Binding { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_add(ctx: *mut Context, + store: *const Store, + label: *const c_char, + fingerprint: *const Fingerprint) + -> *mut Binding { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let store = ffi_param_ref!(store); @@ -226,12 +223,12 @@ pub extern "system" fn sq_store_add(ctx: *mut Context, } /// Imports a key into the store. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_import(ctx: *mut Context, - store: *const Store, - label: *const c_char, - tpk: *const TPK) - -> Maybe<TPK> { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_import(ctx: *mut Context, + store: *const Store, + label: *const c_char, + tpk: *const TPK) + -> Maybe<TPK> { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let store = ffi_param_ref!(store); @@ -242,11 +239,11 @@ pub extern "system" fn sq_store_import(ctx: *mut Context, } /// Returns the binding for the given label. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_lookup(ctx: *mut Context, - store: *const Store, - label: *const c_char) - -> *mut Binding { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_lookup(ctx: *mut Context, + store: *const Store, + label: *const c_char) + -> *mut Binding { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let store = ffi_param_ref!(store); @@ -256,9 +253,8 @@ pub extern "system" fn sq_store_lookup(ctx: *mut Context, } /// Looks up a key in the common key pool by KeyID. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_lookup_by_keyid(ctx: *mut Context, - keyid: *const KeyID) +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_lookup_by_keyid(ctx: *mut Context, keyid: *const KeyID) -> *mut Key { let ctx = ffi_param_ref_mut!(ctx); @@ -269,9 +265,8 @@ pub extern "system" fn sq_store_lookup_by_keyid(ctx: *mut Context, } /// Looks up a key in the common key pool by (Sub)KeyID. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_lookup_by_subkeyid(ctx: *mut Context, - keyid: *const KeyID) +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_lookup_by_subkeyid(ctx: *mut Context, keyid: *const KeyID) -> *mut Key { let ctx = ffi_param_ref_mut!(ctx); @@ -284,10 +279,9 @@ pub extern "system" fn sq_store_lookup_by_subkeyid(ctx: *mut Context, /// Deletes this store. /// /// Consumes `store`. Returns != 0 on error. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_delete(ctx: *mut Context, - store: *mut Store) - -> Status { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_delete(ctx: *mut Context, store: *mut Store) + -> Status { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let store = ffi_param_move!(store); @@ -296,10 +290,9 @@ pub extern "system" fn sq_store_delete(ctx: *mut Context, } /// Lists all bindings. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_iter(ctx: *mut Context, - store: *const Store) - -> *mut BindingIter { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_iter(ctx: *mut Context, store: *const Store) + -> *mut BindingIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let store = ffi_param_ref!(store); @@ -312,11 +305,11 @@ pub extern "system" fn sq_store_iter(ctx: *mut Context, /// Returns `NULL` on exhaustion. If `labelp` is not `NULL`, the /// bindings label is stored there. If `fpp` is not `NULL`, the /// bindings fingerprint is stored there. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_iter_next(iter: *mut BindingIter, - labelp: Option<&mut *mut c_char>, - fpp: Option<&mut Maybe<Fingerprint>>) - -> *mut Binding { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_iter_next(iter: *mut BindingIter, + labelp: Option<&mut *mut c_char>, + fpp: Option<&mut Maybe<Fingerprint>>) + -> *mut Binding { let iter = ffi_param_ref_mut!(iter); match iter.next() { Some((label, fp, binding)) => { @@ -340,16 +333,15 @@ pub extern "system" fn sq_binding_iter_next(iter: *mut BindingIter, } /// Frees a sq_binding_iter_t. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_iter_free(iter: Option<&mut BindingIter>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_iter_free(iter: Option<&mut BindingIter>) { ffi_free!(iter) } /// Lists all log entries related to this store. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_store_log(ctx: *mut Context, - store: *const Store) - -> *mut LogIter { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_store_log(ctx: *mut Context, store: *const Store) + -> *mut LogIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let store = ffi_param_ref!(store); @@ -358,20 +350,20 @@ pub extern "system" fn sq_store_log(ctx: *mut Context, } /// Frees a sq_binding_t. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_free(binding: Option<&mut Binding>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_free(binding: Option<&mut Binding>) { ffi_free!(binding) } /// Frees a sq_key_t. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_key_free(key: Option<&mut Key>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_key_free(key: Option<&mut Key>) { ffi_free!(key) } /// Frees a sq_log_t. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_log_free(log: Option<&mut Log>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_log_free(log: Option<&mut Log>) { if let Some(log) = log { let log = unsafe { Box::from_raw(log) }; if ! log.store.is_null() { @@ -393,10 +385,9 @@ pub extern "system" fn sq_log_free(log: Option<&mut Log>) { } /// Returns the `sq_stats_t` of this binding. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_stats(ctx: *mut Context, - binding: *const Binding) - -> *mut Stats { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_stats(ctx: *mut Context, binding: *const Binding) + -> *mut Stats { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let binding = ffi_param_ref!(binding); @@ -405,10 +396,9 @@ pub extern "system" fn sq_binding_stats(ctx: *mut Context, } /// Returns the `sq_key_t` of this binding. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_key(ctx: *mut Context, - binding: *const Binding) - -> *mut Key { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_key(ctx: *mut Context, binding: *const Binding) + -> *mut Key { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let binding = ffi_param_ref!(binding); @@ -417,10 +407,9 @@ pub extern "system" fn sq_binding_key(ctx: *mut Context, } /// Returns the `pgp_tpk_t` of this binding. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_tpk(ctx: *mut Context, - binding: *const Binding) - -> Maybe<TPK> { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_tpk(ctx: *mut Context, binding: *const Binding) + -> Maybe<TPK> { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let binding = ffi_param_ref!(binding); @@ -444,11 +433,11 @@ pub extern "system" fn sq_binding_tpk(ctx: *mut Context, /// `Error::Conflict` is returned, and you have to resolve the /// conflict, either by ignoring the new key, or by using /// `sq_binding_rotate` to force a rotation. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_import(ctx: *mut Context, - binding: *const Binding, - tpk: *const TPK) - -> Maybe<TPK> { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_import(ctx: *mut Context, + binding: *const Binding, + tpk: *const TPK) + -> Maybe<TPK> { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let binding = ffi_param_ref!(binding); @@ -471,11 +460,11 @@ pub extern "system" fn sq_binding_import(ctx: *mut Context, /// `tpk` properly. How to do that depends on your thread model. /// You could simply ask Alice to call her communication partner /// Bob and confirm that he rotated his keys. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_rotate(ctx: *mut Context, - binding: *const Binding, - tpk: *const TPK) - -> Maybe<TPK> { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_rotate(ctx: *mut Context, + binding: *const Binding, + tpk: *const TPK) + -> Maybe<TPK> { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let binding = ffi_param_ref!(binding); @@ -487,10 +476,10 @@ pub extern "system" fn sq_binding_rotate(ctx: *mut Context, /// Deletes this binding. /// /// Consumes `binding`. Returns != 0 on error. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_delete(ctx: *mut Context, - binding: *mut Binding) - -> Status { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_binding_delete(ctx: *mut Context, + binding: *mut Binding) + -> Status { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let binding = ffi_param_move!(binding); @@ -499,10 +488,10 @@ pub extern "system" fn sq_binding_delete(ctx: *mut Context, } /// Lists all log entries related to this binding. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_binding_log(ctx: *mut Context, - bin |