summaryrefslogtreecommitdiffstats
path: root/ffi/src/sequoia.h
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-02-07 15:24:29 +0100
committerJustus Winter <justus@sequoia-pgp.org>2018-02-13 13:48:36 +0100
commit9a2db67519ad2ec625a1b7c6526353e202c14d2d (patch)
tree1045f3b795a4ba7a54a672530a5802e86c9cd414 /ffi/src/sequoia.h
parent73c02452ee5a8d29c5df5c67cd775755b3b8d64c (diff)
ffi: Improve error reporting.
- Add a new type ffi::Context that provides an error slot. - Functions that can return complex errors can stash the error there, while still be convenient to use. - For now, there is only sq_last_strerror that returns a string representation of the error. In the future we should also return a numeric code, and may want to expose the stack of failures.
Diffstat (limited to 'ffi/src/sequoia.h')
-rw-r--r--ffi/src/sequoia.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/ffi/src/sequoia.h b/ffi/src/sequoia.h
index 30274caa..0a21ef7c 100644
--- a/ffi/src/sequoia.h
+++ b/ffi/src/sequoia.h
@@ -20,6 +20,18 @@
struct sq_context;
/*/
+/// Returns the last error message.
+///
+/// The returned value must be freed with `sq_string_free`.
+/*/
+char *sq_last_strerror (const struct sq_context *ctx);
+
+/*/
+/// Frees a string returned from Sequoia.
+/*/
+void sq_string_free (char *s);
+
+/*/
/// Represents a `Context` configuration.
/*/
struct sq_config;
@@ -230,7 +242,8 @@ struct sq_tpk;
///
/// `buf` must be an OpenPGP encoded message.
/*/
-struct sq_tpk *sq_tpk_from_bytes (const char *b, size_t len);
+struct sq_tpk *sq_tpk_from_bytes (struct sq_context *ctx,
+ const char *b, size_t len);
/*/
/// Frees the TPK.