summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-01-24 13:13:26 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-25 14:04:26 +0100
commit9d6e628d6a183b483bdf115993d0a5a377c3d823 (patch)
treeb03d162178d81795910701a997ec54355aea1c0d /ffi
parent0484d4fca48fd8201fb3506fb4c4ddf5f4c76c83 (diff)
openpgp-ffi: Convert TPK.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/src/net.rs10
-rw-r--r--ffi/src/store.rs35
2 files changed, 24 insertions, 21 deletions
diff --git a/ffi/src/net.rs b/ffi/src/net.rs
index 9c462f4e..5ef0353f 100644
--- a/ffi/src/net.rs
+++ b/ffi/src/net.rs
@@ -34,13 +34,15 @@ use std::slice;
extern crate sequoia_openpgp as openpgp;
-use self::openpgp::TPK;
use sequoia_net::KeyServer;
use super::error::Status;
use super::core::Context;
use ::openpgp::keyid::KeyID;
+use ::openpgp::tpk::TPK;
use ::RefRaw;
+use MoveResultIntoRaw;
+use Maybe;
/// Returns a handle for the given URI.
///
@@ -115,13 +117,13 @@ pub extern "system" fn sq_keyserver_free(ks: Option<&mut KeyServer>) {
pub extern "system" fn sq_keyserver_get(ctx: *mut Context,
ks: *mut KeyServer,
id: *const KeyID)
- -> *mut TPK {
+ -> Maybe<TPK> {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
let ks = ffi_param_ref_mut!(ks);
let id = id.ref_raw();
- ffi_try_box!(ks.get(&id))
+ ks.get(&id).move_into_raw(Some(ctx.errp()))
}
/// Sends the given key to the server.
@@ -135,7 +137,7 @@ pub extern "system" fn sq_keyserver_send(ctx: *mut Context,
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
let ks = ffi_param_ref_mut!(ks);
- let tpk = ffi_param_ref!(tpk);
+ let tpk = tpk.ref_raw();
ffi_try_status!(ks.send(tpk))
}
diff --git a/ffi/src/store.rs b/ffi/src/store.rs
index 4599c0ed..3b4baa50 100644
--- a/ffi/src/store.rs
+++ b/ffi/src/store.rs
@@ -28,7 +28,6 @@ use std::ptr;
extern crate sequoia_openpgp as openpgp;
-use self::openpgp::TPK;
use sequoia_store::{
self, Store, StoreIter, Binding, BindingIter, Key, KeyIter, LogIter, Pool,
};
@@ -38,8 +37,10 @@ use super::core::Context;
use ::openpgp::fingerprint::Fingerprint;
use ::openpgp::keyid::KeyID;
+use ::openpgp::tpk::TPK;
use RefRaw;
use MoveIntoRaw;
+use MoveResultIntoRaw;
use Maybe;
/// Lists all stores with the given prefix.
@@ -230,14 +231,14 @@ pub extern "system" fn sq_store_import(ctx: *mut Context,
store: *const Store,
label: *const c_char,
tpk: *const TPK)
- -> *mut TPK {
+ -> Maybe<TPK> {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
let store = ffi_param_ref!(store);
let label = ffi_param_cstr!(label).to_string_lossy();
- let tpk = ffi_param_ref!(tpk);
+ let tpk = tpk.ref_raw();
- ffi_try_box!(store.import(&label, tpk))
+ store.import(&label, tpk).move_into_raw(Some(ctx.errp()))
}
/// Returns the binding for the given label.
@@ -419,12 +420,12 @@ pub extern "system" fn sq_binding_key(ctx: *mut Context,
#[::ffi_catch_abort] #[no_mangle]
pub extern "system" fn sq_binding_tpk(ctx: *mut Context,
binding: *const Binding)
- -> *mut TPK {
+ -> Maybe<TPK> {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
let binding = ffi_param_ref!(binding);
- ffi_try_box!(binding.tpk())
+ binding.tpk().move_into_raw(Some(ctx.errp()))
}
/// Updates this binding with the given TPK.
@@ -447,13 +448,13 @@ pub extern "system" fn sq_binding_tpk(ctx: *mut Context,
pub extern "system" fn sq_binding_import(ctx: *mut Context,
binding: *const Binding,
tpk: *const TPK)
- -> *mut TPK {
+ -> Maybe<TPK> {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
let binding = ffi_param_ref!(binding);
- let tpk = ffi_param_ref!(tpk);
+ let tpk = tpk.ref_raw();
- ffi_try_box!(binding.import(&tpk))
+ binding.import(&tpk).move_into_raw(Some(ctx.errp()))
}
@@ -474,13 +475,13 @@ pub extern "system" fn sq_binding_import(ctx: *mut Context,
pub extern "system" fn sq_binding_rotate(ctx: *mut Context,
binding: *const Binding,
tpk: *const TPK)
- -> *mut TPK {
+ -> Maybe<TPK> {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
let binding = ffi_param_ref!(binding);
- let tpk = ffi_param_ref!(tpk);
+ let tpk = tpk.ref_raw();
- ffi_try_box!(binding.rotate(&tpk))
+ binding.rotate(&tpk).move_into_raw(Some(ctx.errp()))
}
/// Deletes this binding.
@@ -525,12 +526,12 @@ pub extern "system" fn sq_key_stats(ctx: *mut Context,
#[::ffi_catch_abort] #[no_mangle]
pub extern "system" fn sq_key_tpk(ctx: *mut Context,
key: *const Key)
- -> *mut TPK {
+ -> Maybe<TPK> {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
let key = ffi_param_ref!(key);
- ffi_try_box!(key.tpk())
+ key.tpk().move_into_raw(Some(ctx.errp()))
}
/// Updates this stored key with the given TPK.
@@ -546,13 +547,13 @@ pub extern "system" fn sq_key_tpk(ctx: *mut Context,
pub extern "system" fn sq_key_import(ctx: *mut Context,
key: *const Key,
tpk: *const TPK)
- -> *mut TPK {
+ -> Maybe<TPK> {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
let key = ffi_param_ref!(key);
- let tpk = ffi_param_ref!(tpk);
+ let tpk = tpk.ref_raw();
- ffi_try_box!(key.import(&tpk))
+ key.import(&tpk).move_into_raw(Some(ctx.errp()))
}
/// Lists all log entries related to this key.