diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-03-28 09:28:22 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-04-01 14:24:47 +0200 |
commit | 7b4fb104ddda95f145cbd360f10503a8614dd8b3 (patch) | |
tree | 95435083c1a3e201d6db71338d74b67663d747e2 /openpgp-ffi | |
parent | 82d8ace551e4310df8135f7e6b7eec1d0fe256aa (diff) |
openpgp-ffi: Add a convenience function to pretty print a packet
Diffstat (limited to 'openpgp-ffi')
-rw-r--r-- | openpgp-ffi/include/sequoia/openpgp.h | 2 | ||||
-rw-r--r-- | openpgp-ffi/src/packet/mod.rs | 8 |
2 files changed, 10 insertions, 0 deletions
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 +} + |