summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-02-04 13:28:30 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-02-05 17:17:39 +0100
commit46b7c84f0d8fbb7d8659d70477b26d41ce4d4337 (patch)
tree3f5b10c99a99ec11c159aeea318b0289747631de
parent33233a5743ae333679b3f7300fa552fbbc3d5b48 (diff)
openpgp-ffi: Use a common macro for every exported function.
- This way we can easily introduce new transformations.
-rw-r--r--ffi-macros/src/lib.rs31
-rw-r--r--openpgp-ffi/src/armor.rs12
-rw-r--r--openpgp-ffi/src/common.rs18
-rw-r--r--openpgp-ffi/src/crypto.rs8
-rw-r--r--openpgp-ffi/src/error.rs2
-rw-r--r--openpgp-ffi/src/fingerprint.rs10
-rw-r--r--openpgp-ffi/src/io.rs22
-rw-r--r--openpgp-ffi/src/keyid.rs6
-rw-r--r--openpgp-ffi/src/lib.rs1
-rw-r--r--openpgp-ffi/src/packet/key.rs22
-rw-r--r--openpgp-ffi/src/packet/mod.rs8
-rw-r--r--openpgp-ffi/src/packet/pkesk.rs4
-rw-r--r--openpgp-ffi/src/packet/signature.rs30
-rw-r--r--openpgp-ffi/src/packet/skesk.rs2
-rw-r--r--openpgp-ffi/src/packet/user_attribute.rs2
-rw-r--r--openpgp-ffi/src/packet/userid.rs2
-rw-r--r--openpgp-ffi/src/parse.rs34
-rw-r--r--openpgp-ffi/src/serialize.rs20
-rw-r--r--openpgp-ffi/src/tpk.rs68
-rw-r--r--openpgp-ffi/src/tsk.rs6
20 files changed, 159 insertions, 149 deletions
diff --git a/ffi-macros/src/lib.rs b/ffi-macros/src/lib.rs
index 70dd89c1..e72b610f 100644
--- a/ffi-macros/src/lib.rs
+++ b/ffi-macros/src/lib.rs
@@ -20,6 +20,17 @@ use proc_macro2::TokenStream as TokenStream2;
use quote::{quote, ToTokens};
+/// Transforms exported functions.
+///
+/// This macro is used to decorate every function exported from
+/// Sequoia. It applies the following transformations:
+///
+/// - [ffi_catch_abort](attr.ffi_catch_abort.html)
+#[proc_macro_attribute]
+pub fn extern_fn(attr: TokenStream, item: TokenStream) -> TokenStream {
+ ffi_catch_abort(attr, item)
+}
+
/// Wraps a function's body in a catch_unwind block, aborting on
/// panics.
///
@@ -544,7 +555,7 @@ fn derive_free(span: proc_macro2::Span, prefix: &str, name: &str,
span);
quote! {
/// Frees this object.
- #[::ffi_catch_abort] #[no_mangle]
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn #ident (this: Option<&mut #wrapper>) {
if let Some(ref_) = this {
drop((ref_ as *mut #wrapper).move_from_raw())
@@ -562,7 +573,7 @@ fn derive_clone(span: proc_macro2::Span, prefix: &str, name: &str,
span);
quote! {
/// Clones this object.
- #[::ffi_catch_abort] #[no_mangle]
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn #ident (this: *const #wrapper)
-> *mut #wrapper {
this.ref_raw().clone().move_into_raw()
@@ -579,7 +590,7 @@ fn derive_equal(span: proc_macro2::Span, prefix: &str, name: &str,
span);
quote! {
/// Compares objects.
- #[::ffi_catch_abort] #[no_mangle]
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn #ident (a: *const #wrapper,
b: *const #wrapper)
-> bool {
@@ -599,7 +610,7 @@ fn derive_to_string(span: proc_macro2::Span, prefix: &str, name: &str,
quote! {
/// Returns a human readable description of this object
/// intended for communication with end users.
- #[::ffi_catch_abort] #[no_mangle]
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn #ident (this: *const #wrapper)
-> *mut ::libc::c_char {
ffi_return_string!(format!("{}", this.ref_raw()))
@@ -617,7 +628,7 @@ fn derive_debug(span: proc_macro2::Span, prefix: &str, name: &str,
quote! {
/// Returns a human readable description of this object
/// suitable for debugging.
- #[::ffi_catch_abort] #[no_mangle]
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn #ident (this: *const #wrapper)
-> *mut ::libc::c_char {
ffi_return_string!(format!("{:?}", this.ref_raw()))
@@ -634,7 +645,7 @@ fn derive_hash(span: proc_macro2::Span, prefix: &str, name: &str,
span);
quote! {
/// Hashes this object.
- #[::ffi_catch_abort] #[no_mangle]
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn #ident (this: *const #wrapper)
-> ::libc::uint64_t {
use ::std::hash::{Hash, Hasher};
@@ -662,7 +673,7 @@ fn derive_parse(span: proc_macro2::Span, prefix: &str, name: &str,
span);
quote! {
/// Parses an object from the given reader.
- #[::ffi_catch_abort] #[no_mangle] pub extern "system"
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn #from_reader(errp: Option<&mut *mut ::error::Error>,
reader: *mut Box<::std::io::Read>)
-> ::Maybe<#wrapper> {
@@ -671,7 +682,7 @@ fn derive_parse(span: proc_macro2::Span, prefix: &str, name: &str,
}
/// Parses an object from the given file.
- #[::ffi_catch_abort] #[no_mangle] pub extern "system"
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn #from_file(errp: Option<&mut *mut ::error::Error>,
filename: *const ::libc::c_char)
-> ::Maybe<#wrapper> {
@@ -681,7 +692,7 @@ fn derive_parse(span: proc_macro2::Span, prefix: &str, name: &str,
}
/// Parses an object from the given buffer.
- #[::ffi_catch_abort] #[no_mangle] pub extern "system"
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn #from_bytes(errp: Option<&mut *mut ::error::Error>,
b: *const ::libc::uint8_t, len: ::libc::size_t)
-> ::Maybe<#wrapper> {
@@ -704,7 +715,7 @@ fn derive_serialize(span: proc_macro2::Span, prefix: &str, name: &str,
span);
quote! {
/// Serializes this object.
- #[::ffi_catch_abort] #[no_mangle] pub extern "system"
+ #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn #ident (errp: Option<&mut *mut ::error::Error>,
tsk: *const #wrapper,
writer: *mut Box<::std::io::Write>)
diff --git a/openpgp-ffi/src/armor.rs b/openpgp-ffi/src/armor.rs
index b45cb09a..aef262ad 100644
--- a/openpgp-ffi/src/armor.rs
+++ b/openpgp-ffi/src/armor.rs
@@ -101,7 +101,7 @@ fn kind_to_int(kind: Option<armor::Kind>) -> c_int {
/// pgp_reader_free (armor);
/// pgp_reader_free (bytes);
/// ```
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_armor_reader_new(inner: *mut Box<Read>,
kind: c_int)
-> *mut Box<Read> {
@@ -112,7 +112,7 @@ pub extern "system" fn pgp_armor_reader_new(inner: *mut Box<Read>,
}
/// Creates a `Reader` from a file.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_armor_reader_from_file(errp: Option<&mut *mut ::error::Error>,
filename: *const c_char,
kind: c_int)
@@ -180,7 +180,7 @@ pub extern "system" fn pgp_armor_reader_from_file(errp: Option<&mut *mut ::error
///
/// pgp_reader_free (armor);
/// ```
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_armor_reader_from_bytes(b: *const uint8_t, len: size_t,
kind: c_int)
-> *mut Box<Read> {
@@ -204,7 +204,7 @@ pub extern "system" fn pgp_armor_reader_from_bytes(b: *const uint8_t, len: size_
/// See [this] example.
///
/// [this]: fn.pgp_armor_reader_new.html
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_armor_reader_kind(reader: *mut Box<Read>)
-> c_int {
// We need to downcast `reader`. To do that, we need to do a
@@ -234,7 +234,7 @@ pub extern "system" fn pgp_armor_reader_kind(reader: *mut Box<Read>)
/// See [this] example.
///
/// [this]: fn.pgp_armor_reader_new.html
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_armor_reader_headers(errp: Option<&mut *mut ::error::Error>,
reader: *mut Box<Read>,
len: *mut size_t)
@@ -340,7 +340,7 @@ pub extern "system" fn pgp_armor_reader_headers(errp: Option<&mut *mut ::error::
/// return 0;
/// }
/// ```
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_armor_writer_new
(errp: Option<&mut *mut ::error::Error>,
inner: *mut Box<Write>,
diff --git a/openpgp-ffi/src/common.rs b/openpgp-ffi/src/common.rs
index 9d430a69..ba2ce7d2 100644
--- a/openpgp-ffi/src/common.rs
+++ b/openpgp-ffi/src/common.rs
@@ -327,7 +327,7 @@ fn revocation_status_to_int(rs: &RevocationStatus) -> c_int {
}
/// Returns the TPK's revocation status variant.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_revocation_status_variant(
rs: *mut RevocationStatus)
-> c_int
@@ -339,7 +339,7 @@ pub extern "system" fn pgp_revocation_status_variant(
}
/// Frees a pgp_revocation_status_t.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_revocation_status_free(
rs: Option<&mut RevocationStatus>)
{
@@ -349,7 +349,7 @@ pub extern "system" fn pgp_revocation_status_free(
// Secret.
/// Creates an pgp_secret_t from a decrypted session key.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub fn pgp_secret_cached<'a>(algo: u8,
session_key: *const u8,
session_key_len: size_t)
@@ -398,7 +398,7 @@ pub struct VerificationResults<'a> {
/// This function returns the verification results for a particular
/// level. The result is an array of references to
/// `VerificationResult`.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub fn pgp_verification_results_at_level<'a>(results: *const VerificationResults<'a>,
level: size_t,
r: *mut *const &'a VerificationResult,
@@ -417,7 +417,7 @@ pub fn pgp_verification_results_at_level<'a>(results: *const VerificationResults
}
/// Returns the verification result code.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub fn pgp_verification_result_code(result: *const VerificationResult)
-> c_int
{
@@ -430,7 +430,7 @@ pub fn pgp_verification_result_code(result: *const VerificationResult)
}
/// Returns the verification result code.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub fn pgp_verification_result_signature(result: *const VerificationResult)
-> *const self::openpgp::packet::Signature
{
@@ -445,7 +445,7 @@ pub fn pgp_verification_result_signature(result: *const VerificationResult)
}
/// Returns the verification result code.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub fn pgp_verification_result_level(result: *const VerificationResult)
-> c_int
{
@@ -622,7 +622,7 @@ fn verify_real<'a>(input: &'a mut Box<'a + Read>,
/// treated as opaque containers.
///
/// Note: output may be NULL, if the output is not required.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub fn pgp_verify<'a>(errp: Option<&mut *mut ::error::Error>,
input: *mut Box<'a + Read>,
dsig: Option<&'a mut Box<'a + Read>>,
@@ -745,7 +745,7 @@ fn decrypt_real<'a>(input: &'a mut Box<'a + Read>,
/// first parameter to each of them.
///
/// Note: all of the parameters are required; none may be NULL.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub fn pgp_decrypt<'a>(errp: Option<&mut *mut ::error::Error>,
input: *mut Box<'a + Read>,
output: *mut Box<'a + Write>,
diff --git a/openpgp-ffi/src/crypto.rs b/openpgp-ffi/src/crypto.rs
index eebd7f3a..82bb1707 100644
--- a/openpgp-ffi/src/crypto.rs
+++ b/openpgp-ffi/src/crypto.rs
@@ -11,7 +11,7 @@ use self::sequoia_openpgp::{
};
/// Frees a signer.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_signer_free
(s: Option<&mut &'static mut crypto::Signer>)
{
@@ -19,7 +19,7 @@ pub extern "system" fn pgp_signer_free
}
/// Creates a new key pair.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_pair_new
(errp: Option<&mut *mut ::error::Error>, public: *mut Key, secret: *mut crypto::mpis::SecretKey)
-> *mut crypto::KeyPair
@@ -31,7 +31,7 @@ pub extern "system" fn pgp_key_pair_new
}
/// Frees a key pair.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_pair_free
(kp: Option<&mut crypto::KeyPair>)
{
@@ -42,7 +42,7 @@ pub extern "system" fn pgp_key_pair_free
///
/// Note that the returned object merely references the key pair, and
/// must not outlive the key pair.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_pair_as_signer
(kp: *mut crypto::KeyPair)
-> *mut &'static mut crypto::Signer
diff --git a/openpgp-ffi/src/error.rs b/openpgp-ffi/src/error.rs
index ffed2be7..5a8bf4ab 100644
--- a/openpgp-ffi/src/error.rs
+++ b/openpgp-ffi/src/error.rs
@@ -31,7 +31,7 @@ impl MoveResultIntoRaw<::error::Status> for ::failure::Fallible<()>
}
/// Returns the error status code.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_error_status(error: *const Error)
-> Status {
error.ref_raw().into()
diff --git a/openpgp-ffi/src/fingerprint.rs b/openpgp-ffi/src/fingerprint.rs
index 07dabf2c..b3917236 100644
--- a/openpgp-ffi/src/fingerprint.rs
+++ b/openpgp-ffi/src/fingerprint.rs
@@ -33,7 +33,7 @@ use Maybe;
pub struct Fingerprint(openpgp::Fingerprint);
/// Reads a binary fingerprint.
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn pgp_fingerprint_from_bytes(buf: *const uint8_t,
len: size_t)
-> *mut Fingerprint {
@@ -64,7 +64,7 @@ fn pgp_fingerprint_from_bytes(buf: *const uint8_t,
/// free (pretty);
/// pgp_fingerprint_free (fp);
/// ```
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn pgp_fingerprint_from_hex(hex: *const c_char)
-> Maybe<Fingerprint> {
let hex = ffi_param_cstr!(hex).to_string_lossy();
@@ -75,7 +75,7 @@ fn pgp_fingerprint_from_hex(hex: *const c_char)
///
/// This returns a reference to the internal buffer that is valid as
/// long as the fingerprint is.
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn pgp_fingerprint_as_bytes(fp: *const Fingerprint,
fp_len: Option<&mut size_t>)
-> *const uint8_t {
@@ -87,14 +87,14 @@ fn pgp_fingerprint_as_bytes(fp: *const Fingerprint,
}
/// Converts the fingerprint to a hexadecimal number.
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn pgp_fingerprint_to_hex(fp: *const Fingerprint)
-> *mut c_char {
ffi_return_string!(fp.ref_raw().to_hex())
}
/// Converts the fingerprint to a key ID.
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn pgp_fingerprint_to_keyid(fp: *const Fingerprint)
-> *mut KeyID {
fp.ref_raw().to_keyid().move_into_raw()
diff --git a/openpgp-ffi/src/io.rs b/openpgp-ffi/src/io.rs
index 436b6619..e6ca0eda 100644
--- a/openpgp-ffi/src/io.rs
+++ b/openpgp-ffi/src/io.rs
@@ -10,7 +10,7 @@ use libc::{uint8_t, c_void, c_char, c_int, size_t, ssize_t, realloc};
use std::os::unix::io::FromRawFd;
/// Opens a file returning a reader.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_reader_from_file(errp: Option<&mut *mut ::error::Error>,
filename: *const c_char)
-> *mut Box<Read> {
@@ -23,14 +23,14 @@ pub extern "system" fn pgp_reader_from_file(errp: Option<&mut *mut ::error::Erro
/// Opens a file descriptor returning a reader.
#[cfg(unix)]
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_reader_from_fd(fd: c_int)
-> *mut Box<Read> {
box_raw!(Box::new(unsafe { File::from_raw_fd(fd) }))
}
/// Creates a reader from a buffer.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_reader_from_bytes(buf: *const uint8_t,
len: size_t)
-> *mut Box<Read> {
@@ -42,13 +42,13 @@ pub extern "system" fn pgp_reader_from_bytes(buf: *const uint8_t,
}
/// Frees a reader.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_reader_free(reader: Option<&mut Box<Read>>) {
ffi_free!(reader)
}
/// Reads up to `len` bytes into `buf`.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_reader_read(errp: Option<&mut *mut ::error::Error>,
reader: *mut Box<Read>,
buf: *mut uint8_t, len: size_t)
@@ -67,7 +67,7 @@ pub extern "system" fn pgp_reader_read(errp: Option<&mut *mut ::error::Error>,
///
/// The file will be created if it does not exist, or be truncated
/// otherwise. If you need more control, use `pgp_writer_from_fd`.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_writer_from_file(errp: Option<&mut *mut ::error::Error>,
filename: *const c_char)
-> *mut Box<Write> {
@@ -80,14 +80,14 @@ pub extern "system" fn pgp_writer_from_file(errp: Option<&mut *mut ::error::Erro
/// Opens a file descriptor returning a writer.
#[cfg(unix)]
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_writer_from_fd(fd: c_int)
-> *mut Box<Write> {
box_raw!(Box::new(unsafe { File::from_raw_fd(fd) }))
}
/// Creates a writer from a buffer.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_writer_from_bytes(buf: *mut uint8_t,
len: size_t)
-> *mut Box<Write> {
@@ -106,7 +106,7 @@ pub extern "system" fn pgp_writer_from_bytes(buf: *mut uint8_t,
/// reference a chunk of memory allocated using libc's heap allocator.
/// The caller is responsible to `free` it once the writer has been
/// destroyed.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_writer_alloc(buf: *mut *mut c_void,
len: *mut size_t)
-> *mut Box<Write> {
@@ -153,13 +153,13 @@ impl Write for WriterAlloc {
}
/// Frees a writer.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_writer_free(writer: Option<&mut Box<Write>>) {
ffi_free!(writer)
}
/// Writes up to `len` bytes of `buf` into `writer`.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_writer_write(errp: Option<&mut *mut ::error::Error>,
writer: *mut Box<Write>,
buf: *const uint8_t, len: size_t)
diff --git a/openpgp-ffi/src/keyid.rs b/openpgp-ffi/src/keyid.rs
index 7236da89..fca6b3b4 100644
--- a/openpgp-ffi/src/keyid.rs
+++ b/openpgp-ffi/src/keyid.rs
@@ -50,7 +50,7 @@ pub struct KeyID(openpgp::KeyID);
/// pgp_keyid_free (mr_b);
/// free (mr_b_as_string);
/// ```
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn pgp_keyid_from_bytes(id: *const uint8_t) -> *mut KeyID {
assert!(!id.is_null());
let id = unsafe { slice::from_raw_parts(id, 8) };
@@ -75,14 +75,14 @@ fn pgp_keyid_from_bytes(id: *const uint8_t) -> *mut KeyID {
/// free (mr_b_as_string);
/// pgp_keyid_free (mr_b);
/// ```
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn pgp_keyid_from_hex(id: *const c_char) -> Maybe<KeyID> {
let id = ffi_param_cstr!(id).to_string_lossy();
openpgp::KeyID::from_hex(&id).ok().move_into_raw()
}
/// Converts the KeyID to a hexadecimal number.
-#[::ffi_catch_abort] #[no_mangle] pub extern "system"
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "system"
fn pgp_keyid_to_hex(id: *const KeyID) -> *mut c_char {
ffi_return_string!(id.ref_raw().to_hex())
}
diff --git a/openpgp-ffi/src/lib.rs b/openpgp-ffi/src/lib.rs
index 54f37eb5..6572b2be 100644
--- a/openpgp-ffi/src/lib.rs
+++ b/openpgp-ffi/src/lib.rs
@@ -322,7 +322,6 @@ extern crate memsec;
extern crate sequoia_ffi_macros;
use sequoia_ffi_macros::{
- ffi_catch_abort,
ffi_wrapper_type,
};
diff --git a/openpgp-ffi/src/packet/key.rs b/openpgp-ffi/src/packet/key.rs
index 9bac8089..83785efc 100644
--- a/openpgp-ffi/src/packet/key.rs
+++ b/openpgp-ffi/src/packet/key.rs
@@ -14,7 +14,7 @@ use self::openpgp::{
};
/// Clones the key.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_clone(key: *const packet::Key)
-> *mut packet::Key {
let key = ffi_param_ref!(key);
@@ -23,7 +23,7 @@ pub extern "system" fn pgp_key_clone(key: *const packet::Key)
/// Computes and returns the key's fingerprint as per Section 12.2
/// of RFC 4880.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_fingerprint(key: *const packet::Key)
-> *mut Fingerprint {
let key = ffi_param_ref!(key);
@@ -32,7 +32,7 @@ pub extern "system" fn pgp_key_fingerprint(key: *const packet::Key)
/// Computes and returns the key's key ID as per Section 12.2 of RFC
/// 4880.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_keyid(key: *const packet::Key)
-> *mut KeyID {
let key = ffi_param_ref!(key);
@@ -45,7 +45,7 @@ pub extern "system" fn pgp_key_keyid(key: *const packet::Key)
/// Note: this is with respect to the provided signature, which is not
/// checked for validity. That is, we do not check whether the
/// signature is a valid self-signature for the given key.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_expired(key: *const packet::Key,
sig: *const packet::Signature)
-> bool
@@ -57,7 +57,7 @@ pub extern "system" fn pgp_key_expired(key: *const packet::Key,
}
/// Like pgp_key_expired, but at a specific time.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_expired_at(key: *const packet::Key,
sig: *const packet::Signature,
when: time_t)
@@ -78,7 +78,7 @@ pub extern "system" fn pgp_key_expired_at(key: *const packet::Key,
/// Note: this is with respect to the provided signature, which is not
/// checked for validity. That is, we do not check whether the
/// signature is a valid self-signature for the given key.
-#[::ffi_catch_abort] #[no_mangle]
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "system" fn pgp_key_alive(key: *const packet::Key,
sig: *const packet::Signature)
-> bool
@@ -90,7 +90,7 @@ pub exte