From 7b4fb104ddda95f145cbd360f10503a8614dd8b3 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Thu, 28 Mar 2019 09:28:22 +0100 Subject: openpgp-ffi: Add a convenience function to pretty print a packet --- openpgp-ffi/include/sequoia/openpgp.h | 2 ++ openpgp-ffi/src/packet/mod.rs | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'openpgp-ffi') diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index aad66926..73bcc7a6 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -51,6 +51,8 @@ char *pgp_keyid_to_string (const pgp_keyid_t fp); /*/ char *pgp_keyid_debug (const pgp_keyid_t fp); +char *pgp_packet_debug (const pgp_packet_t fp); + /*/ /// Converts the KeyID to a hexadecimal number. /*/ diff --git a/openpgp-ffi/src/packet/mod.rs b/openpgp-ffi/src/packet/mod.rs index a2d557e3..52ffaee5 100644 --- a/openpgp-ffi/src/packet/mod.rs +++ b/openpgp-ffi/src/packet/mod.rs @@ -91,3 +91,11 @@ pub extern "system" fn pgp_tag_to_string(tag: uint8_t) -> *const c_char { _ => "OTHER\x00", }.as_bytes().as_ptr() as *const c_char } + +/// Pretty prints a packet +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] +pub extern "system" fn pgp_packet_debug(p: *const Packet) -> *const c_char { + let p = ffi_param_ref!(p); + format!("{:?}", p).as_ptr() as *const c_char +} + -- cgit v1.2.3