blob: c26e9cce46d89f95fb1735244573156fb8e9a8fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
//! User Attribute packets.
//!
//! See [Section 5.12 of RFC 4880] for details.
//!
//! [Section 5.12 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.12
use libc::{uint8_t, size_t};
extern crate sequoia_openpgp as openpgp;
use super::Packet;
use RefRaw;
/// Returns the value of the User Attribute Packet.
///
/// The returned pointer is valid until `ua` is deallocated. If
/// `value_len` is not `NULL`, the size of value is stored there.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "C" fn pgp_user_attribute_value(ua: *const Packet,
value_len: Option<&mut size_t>)
-> *const uint8_t {
if let &openpgp::Packet::UserAttribute(ref ua) = ua.ref_raw() {
if let Some(p) = value_len {
*p = ua.value().len();
}
ua.value().as_ptr()
} else {
panic!("Not a UserAttribute packet");
}
}
|