summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-02-26 15:06:08 +0100
committerJustus Winter <justus@sequoia-pgp.org>2018-02-26 15:07:25 +0100
commit27b871c9db98663157eaf87f0cdd3c5dd1c458e1 (patch)
tree923273c1736596983be29debf8060dafee8a9193 /ffi
parent8fa143e1b99d5c2f06124d7e1ced79d5bc981c73 (diff)
ffi: Add glue for equality predicates.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/include/sequoia/openpgp.h10
-rw-r--r--ffi/src/openpgp.rs20
2 files changed, 30 insertions, 0 deletions
diff --git a/ffi/include/sequoia/openpgp.h b/ffi/include/sequoia/openpgp.h
index 398ee67e..968e31a9 100644
--- a/ffi/include/sequoia/openpgp.h
+++ b/ffi/include/sequoia/openpgp.h
@@ -35,6 +35,11 @@ char *sq_keyid_to_string (const sq_keyid_t fp);
/*/
char *sq_keyid_to_hex (const sq_keyid_t fp);
+/*/
+/// Compares KeyIDs.
+/*/
+int sq_keyid_equal (const sq_keyid_t a, const sq_keyid_t b);
+
/* sequoia::openpgp::Fingerprint. */
@@ -73,6 +78,11 @@ char *sq_fingerprint_to_hex (const sq_fingerprint_t fp);
/*/
sq_keyid_t sq_fingerprint_to_keyid (const sq_fingerprint_t fp);
+/*/
+/// Compares Fingerprints.
+/*/
+int sq_fingerprint_equal (const sq_fingerprint_t a, const sq_fingerprint_t b);
+
/* sequoia::keys. */
diff --git a/ffi/src/openpgp.rs b/ffi/src/openpgp.rs
index 585c2a3c..2564b167 100644
--- a/ffi/src/openpgp.rs
+++ b/ffi/src/openpgp.rs
@@ -61,6 +61,16 @@ pub extern "system" fn sq_keyid_to_hex(id: Option<&KeyID>)
.into_raw()
}
+/// Compares KeyIDs.
+#[no_mangle]
+pub extern "system" fn sq_keyid_equal(a: Option<&KeyID>,
+ b: Option<&KeyID>)
+ -> bool {
+ let a = a.expect("KeyID 'a' is NULL");
+ let b = b.expect("KeyID 'b' is NULL");
+ a == b
+}
+
/* sequoia::openpgp::Fingerprint. */
@@ -124,6 +134,16 @@ pub extern "system" fn sq_fingerprint_to_keyid(fp: Option<&Fingerprint>)
Box::into_raw(Box::new(fp.to_keyid()))
}
+/// Compares Fingerprints.
+#[no_mangle]
+pub extern "system" fn sq_fingerprint_equal(a: Option<&Fingerprint>,
+ b: Option<&Fingerprint>)
+ -> bool {
+ let a = a.expect("Fingerprint 'a' is NULL");
+ let b = b.expect("Fingerprint 'b' is NULL");
+ a == b
+}
+
/* sequoia::keys. */