From 06db1756bbb0ff0f3e8f9f7c4b8ca9d2e1b70d7c Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Wed, 17 Jun 2020 08:51:31 +0200 Subject: openpgp-ffi: Change return type. - Change `pgp_user_id_amalgamation_user_id` and `pgp_valid_user_id_amalgamation_user_id` to return a `pgp_packet_t`, not a `pgp_user_id_t`. - Most functions work with `pgp_packet_t`s, not `pgp_user_id_t`s. --- openpgp-ffi/include/sequoia/openpgp.h | 16 ++++------------ openpgp-ffi/src/amalgamation.rs | 12 ++++++------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index 580134ee..396cbf95 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -573,15 +573,11 @@ void pgp_literal_free (pgp_literal_t literal); /* openpgp::amalgamation::UserIDAmalgamation. */ /*/ -/// Returns the user id. -/// -/// This function may fail and return NULL if the user id contains an -/// interior NUL byte. We do this rather than complicate the API, as -/// there is no valid use for such user ids; they must be malicious. +/// Returns a copy of the user id. /// /// The caller must free the returned value. /*/ -char *pgp_user_id_amalgamation_user_id (pgp_user_id_amalgamation_t ua); +pgp_packet_t pgp_user_id_amalgamation_user_id (pgp_user_id_amalgamation_t ua); /*/ /// Frees the User ID Amalgamation. @@ -600,15 +596,11 @@ pgp_user_id_amalgamation_t pgp_user_id_amalgamation_clone (pgp_user_id_amalgamat char *pgp_user_id_amalgamation_debug (const pgp_user_id_amalgamation_t ua); /*/ -/// Returns the user id. -/// -/// This function may fail and return NULL if the user id contains an -/// interior NUL byte. We do this rather than complicate the API, as -/// there is no valid use for such user ids; they must be malicious. +/// Returns a copy of the user id. /// /// The caller must free the returned value. /*/ -pgp_user_id_t pgp_valid_user_id_amalgamation_user_id +pgp_packet_t pgp_valid_user_id_amalgamation_user_id (pgp_valid_user_id_amalgamation_t ua); /*/ diff --git a/openpgp-ffi/src/amalgamation.rs b/openpgp-ffi/src/amalgamation.rs index 7f75751d..18cf83e8 100644 --- a/openpgp-ffi/src/amalgamation.rs +++ b/openpgp-ffi/src/amalgamation.rs @@ -12,7 +12,7 @@ extern crate sequoia_openpgp as openpgp; use self::openpgp::cert::amalgamation::ValidAmalgamation as _; use self::openpgp::cert::amalgamation::ValidateAmalgamation as _; -use super::packet::userid::UserID; +use super::packet::Packet; use super::packet::signature::Signature; use super::policy::Policy; use super::revocation_status::RevocationStatus; @@ -37,14 +37,14 @@ type UserIDAmalgamationType<'a> derive = "Clone, Debug")] pub struct UserIDAmalgamation<'a>(UserIDAmalgamationType<'a>); -/// Returns a reference to the `UserID`. +/// Returns a copy of the `UserID`. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_user_id_amalgamation_user_id<'a>(ua: *const UserIDAmalgamation<'a>) - -> *const UserID + -> *mut Packet { let ua = ua.ref_raw(); - ua.userid().move_into_raw() + openpgp::Packet::from(ua.userid().clone()).move_into_raw() } /// A local alias to appease the proc macro transformation. @@ -64,11 +64,11 @@ pub struct ValidUserIDAmalgamation<'a>(ValidUserIDAmalgamationType<'a>); /// Returns a reference to the `UserID`. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_valid_user_id_amalgamation_user_id<'a>(ua: *const ValidUserIDAmalgamation<'a>) - -> *const UserID + -> *const Packet { let ua = ua.ref_raw(); - ua.userid().move_into_raw() + openpgp::Packet::from(ua.userid().clone()).move_into_raw() } /// Returns the UserID's revocation status. -- cgit v1.2.3